[Gtk-sharp-list] gtk.entry validation difficulty

Chris Howie cdhowie at gmail.com
Wed May 21 15:52:22 EDT 2008

On Wed, May 21, 2008 at 3:48 PM, Jesper K. Pedersen <linux at famped.dk> wrote:
> In connection with a small application I am writing I have run into a
> slight problem.
> I have a form consisting of several gtk.entry widgets and two buttons
> for "cancel" and "accept"
> Each gtk.entry needs data validated when it is edited (changed)
> meaning when you either press enter or try to deselect the entry (by
> for instance tab'ing/clicking on another entry) my program should
> validate the content of the entry... Except in the case where you press
> the "cancel" button which should just disregard all validation.
> Currently my software is running fine if users don't do anything but use
> "enter" to finalize data entry. I use the Entry.Activated handler to
> validate my input. Unfortunately we have users who are creative with
> using both the tabulate key and the mouse too.
> I have tried using the Entry.EditingDone handler but I cannot get the
> event to fire at all (the GUI is made in glade).
> I have also tried using the Widget.FocusOutEvent but then trying to
> press the "cancel" button will fire the validation event.
> Any idea's/suggestions on how to get around this problem?

If validating the data isn't too resource-intensive (like CPU or DB
connection, etc) just do what I do: have all of the entries' Changed
signal call one method that validates the data and sets the Accept
button's Sensitive property accordingly.  Then users also get visual
feedback while they are typing.

If this would be too slow then you could perform this validation when
an entry loses focus instead.

Chris Howie

More information about the Gtk-sharp-list mailing list