[Gtk-sharp-list] catching enter key in Gtk.Entry
Charles Iliya Krempeaux
charles@reptile.ca
11 Apr 2003 12:20:00 -0700
Hello,
On Tue, 2003-03-18 at 23:58, olterman@dataphone.se wrote:
> Is there an event to catch the enterkey ?
Yes.
For whatever widget you have, you need to hook into the
KeyPressEvent.
You can do this with something like the following...
Gtk.Widget w = // Something that is a descendent of Gtk.Widget
// or Gtk.Widget itself.
w.KeyPressEvent +=
new GtkSharp.KeyPressEventHandler(MyKeyPressedEventHandler);
And, I could define "MyKeyPressedEventHandler" to be something like:
static void MyKeyPressedEventHandler(object o,
GtkSharp.KeyPressEventArgs args)
{
Gdk.EventKey k = args.Event;
if (65293 == k.keyval) {
System.Console.WriteLine("The Enter key was pressed");
}
}
You probably shouldn't use the literal "65293". There's probably
some set of constants that you can use instead. (Maybe something
like "Gdk.Key.Enter".) But I'm not sure what it is.
See ya
--
Charles Iliya Krempeaux, BSc
charles@reptile.ca
________________________________________________________________________
Reptile Consulting & Services 604-REPTILE http://www.reptile.ca/