Re: Forcing focus to a GtkEntry



On Tue, 13 Jun 2000, Gian Luigi Gragnani wrote:

 Hi, 

> Hello all
> I have the following problem:
> I have a window with many entries and I want to validate the text in an
> entry
> when the focus-out signal is received, and force the focus to stay in
> the same entry if its present text is not valid.
> I have tried gtk_widget_grab_focus but it works when just one entry has
> to be checked; instead, if the focus is passed to another entry needing
> validation
> the is a sort of oscillation between the two entries (both trying of
> gaining focus) and the system become unusable.
> Do you know a possible soluiton to this problem

 Seems gtk functions correctly - it behaves as you directed to it - on leaving
entry the focus is returned back to it. So your approach is incorrect.
 I in such cases connect to "changed" signal of all entries in the form the
same validating function that will validate ALL entries in the form and will
disable "OK" button if any is invalid (it could change the color of the text
of entries with bad content as well). Yes, it's very resource consuming
compared to only checking the entry that just changed, but in total even
validation of entire form on each keypress takes very small CPU time.

> Thank you in advance.
> 
> 
> G. L. Gragnani
> -- 
>  Gian Luigi Gragnani               DIBE -  University of Genoa
>  Via Opera Pia 11A             16145 Genova              Italy
>  Tel.   + 39 010 353 2244             Fax    + 39 010 353 2245
>  mailto:gragnani@dibe.unige.it
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-list
> 

 Best regards,
  -Vlad





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