GtkEntry and validating user input
- From: Roger Leigh <roger whinlatter uklinux net>
- To: gtk-list gnome org
- Subject: GtkEntry and validating user input
- Date: Wed, 19 Nov 2003 23:13:05 +0000
In many places, I get user input using a GtkEntry (well, Gtk::Entry,
since I'm using Gtkmm). I'd like to validate the input and, if the
input is invalid, set the background colour of the Entry to red and
restore focus to the Entry, if needed.
I can do this by connecting to the "changed" signal of the
GtkEditable. This works just fine when I want to filter the user
input (I just read the text in the Editable, strip out any unwanted
bits and set it with the new text). However, I really only want to do
the validation (and highlighting in red) when the user has finished
typing, either when they focus out or press Enter.
When I tried this validation in the "activate" signal, this didn't
work: it activated the default widget, which was the OK button of the
dialog. I couldn't prevent the dialog returning RESPONSE_OK, even
when there was an error. How can I prevent this happening? Should
returning false in the "focus-out-event" signal handler stop this?
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
] [Thread Prev