[Gtk-sharp-list] Gtk.Entry Validation and Input
doza at sztorm.net
Sun Nov 5 18:10:21 EST 2006
Dnia 05-11-2006, nie o godzinie 18:08 -0400, Roberto Rodriguez Alcala
> Hi all, i'm a newbie in Gtk# I've been using it for 5 months but with
> basic things.
> Now I need to Force a Single Line Entry to do Overwrite, I tried to
> use ProcessEvent but with no succes.
> And then I tried to validate using TextInserted and TextDeleted
> events, but they are very complex because when I modify the entry it
> calls itself again, and there are a lot of combinations to handle.
> I didn't find a way to modify a entry.text skipping the handlers, so i'm stuck.
> Is there anything I'm mising or a better way to do that? (Ex. Date
> Input validation with automatic separators in a forced overwrite mode)
Answering by question: are you sure you want to do it? Validating data
on single character is in most cases bad choice. It makes harder for
users to correct typos and results in complicated code.
You possibly could do it when entry loses focus. You may then block
"accept" button and display appropriate warning. You may also consider
using multiple Entries to force specific data format, or a TextView with
Additionally you may restrict the set of accepted characters (but not
depending on already entered ones) or provide some indicator, like
special background color of the entry or special icon that shows the
user whether data is correct or not on single character basis, but does
not blocking xyrs input.
xmpp:doza at sztorm.net
More information about the Gtk-sharp-list