[Gtk-sharp-list] GtkEntry input validation

Jesper K. Pedersen jkp at solnet.homeip.net
Fri Dec 8 18:00:04 EST 2006


Being completely new with Gtk# I have been trying to write a small
"getting started" application.
It is just a small calculator to learn about the various gui controls
and just getting into the C# programming language.

I have run into a difficulty of limiting the input of the entry/result
display to only allow for certain characters (currently I only do math
with the common "10" digit system + ".")

I did take a peek at the Gtk+ FAQ showing an example in C + Gtk about
validating input (section 6.15 "How do I validate/limit/filter the
input to a GtkEntry? [GTK 2.x]").

Do anyone have any similar piece of code for the Gtk# ?

What I in essense is trying is to read off any keypress events in my
window and if they are a digit/dot enter them into the calculator
display (of type GtkEntry)

One of my problems is that just setting the GtkEntry editable to false
still doesnt let my keypress event handler get the event for things
like <backspace> <del> and so on (I suspect they are "eaten" by the
GtkEntry)

Any ideas is greatly appreciated to this "newbie" programmer in C#/Gtk#

Best regards
Jesper K. Pedersen


More information about the Gtk-sharp-list mailing list