Re: Validate entry in Gtk::Entry



On 03/22/01 Chris Dunlop wrote:
Your suggestion did exactly what I wanted.  Thanks for you help, and, of
course, thanks for your work on Gtk-Perl.

As it's not completely obvious how to do this type of "field validation
on focus out" it might be worthwhile adding an example of it to the
Gtk-Perl FAQ (if there is one - or do we rely on the Gtk FAQ ?), and/or
the tutorial.  The cookbook example of validating text using the
insert_text signal is great for making sure each character is "correct
within context" e.g. all digits or all uppercase etc., but it doesn't
allow for things where you can only check validity when you have the
complete entry eg. checking for a valid date where you'd like to accept
various formats like "30/03/2001" or "2001-03-30" or "30 March 01" etc.,
and you'd also like to reject invalid dates like "31/02/2001".

I'd really like if someone writes a fully-fledged validating
entry: it could prove really useful, but it's also tricky to
get right in all cases. Someone wants to check for wrong chars as soon
as they are entered and someone only at focus out event. Someone
wants the entry to show "(39) 049.456.292", but actually return
"39049456292" to the program. And what do you do when the user copies
the text to the clipboard? The widget should also skip past some
character that is inserted by default: this is useful in an "IP address"
entry where the default text is "___.___.___.___" and as soon as the user
inserts the first triplet, it skips the dot automatically (and doesn't allow
it to be deleted).  The possibilities are endless.
I'll accept a validating entry widget in the standard distribution
that allows me to do all the above.

lupus

-- 
-----------------------------------------------------------------
lupus debian org                                     debian/rules
lupus ximian com                             Monkeys do it better




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