[Gtk-sharp-list] GtkEntry input validation
Jacob Ilsø Christensen
jacobilsoe at gmail.com
Fri Dec 8 19:23:11 EST 2006
On 12/9/06, Jesper K. Pedersen <jkp at solnet.homeip.net> wrote:
> 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# ?
This works for me:
I don't know if there is a better way...
> 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
> Any ideas is greatly appreciated to this "newbie" programmer in C#/Gtk#
> Best regards
> Jesper K. Pedersen
> Gtk-sharp-list maillist - Gtk-sharp-list at lists.ximian.com
More information about the Gtk-sharp-list