[Gtk-sharp-list] KeyPressEvent not responding to
space/enter/up/down/left/right
Mike Voytovich
mikevoyt at gmail.com
Wed Jul 27 20:24:52 EDT 2005
Hi,
I'm trying to receive keypress events in a window, and am registering
a KeyPressEventHandler.
The KeyPressEventHandler receives an event for all of the keys, except
for the ones I'm interested in, which are
space/enter/up/down/left/right. It correctly receives an event for
control keys, space, caps, function keys, etc.
Example code is shown below to illustrate the problem I'm seeing.
I'm a newbie to gtk and gtk-sharp, my apologizes in advance if this is
a trivial question.
regards,
-mike
*
* simple test app to illustrate key events not receiving
enter/space/up/down/left/right
* keys
*/
using System;
using Gtk;
using GLib;
using System.Runtime.InteropServices;
using System.Threading;
using System.Diagnostics;
public class example {
static void keypress_event(object obj, KeyPressEventArgs args)
{
System.Console.WriteLine("Keypress: {0}", args.Event.Key);
}
public static void Main() {
Application.Init();
Window myWin = new Window("GTK# test app");
myWin.KeyPressEvent += new KeyPressEventHandler(keypress_event);
myWin.ShowAll();
Application.Run();
}
}
More information about the Gtk-sharp-list
mailing list