An easier way to validate a GtkEntry is needed



Hi,

I have been experimenting with ways to to validate the contents
of a GtkEntry and I have not found an easy way to do it.

The obvious time to validate the contents of a GtkEntry is when
the focus leaves the GtkEntry. I dont believe it is a good idea
to force the user to press the enter key to indicate that typing
has finished in the GtkEntry.

The behaviour that I think that the user has come to expect is :
1. The user types text into a GtkEntry.
2. The user clicks onto a different widget which causes the
   focus to leave the GtkEntry.
3. Validation of the text typed into the GtkEntry is performed
   when the focus leaves the GtkEntry.
4. If the text in the GtkEntry is invalid then a modal dialog box
   is shown.
5. When the modal dialog box is closed, the focus returns to the 
   GtkEntry that has invalid text in it.

The problem is that when the user clicks on a different widget,
the button-press-event is delivered to the different widget BEFORE
the focus-out-event is delivered to the GtkEntry. This is not
good because the different widget may take some unwanted
action because the text in the GtkEntry must be valid before any
other action can be taken.

What this means is that the validation for the GtkEntry must be
performed in the button-press-event handler of every widget
other than the GtkEntry. I think this is unwieldy.

I have tried using g_signal_connect_after() for the focus-out-event
but it makes no difference, the events are still delivered in the same
order.

Is there a way to do what I want? If not, I think that an easier way to
validate a GtkEntry is needed.

Regards,

Scott.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]