On Tue, Aug 01, 2006 at 03:38:19PM +0100, Richard Vaughan wrote: > I am trying to capture key presses in a window, but the window seems > to be ignoring the signals. I suppose you mean a drawing area widget as your code indicates, not a GtkWindow (you should have no problems receiving GtkWindow's keyboard events). > > GtkWidget* mainWindow = gtk_drawing_area_new(); > ... > gtk_widget_add_events(mainWindow, (GDK_KEY_RELEASE_MASK | GDK_KEY_PRESS_MASK)); > gtk_signal_connect(GTK_OBJECT( mainWindow ), > "key_press_event", > G_CALLBACK( key_press_win ), > NULL); Note gtk_signal_connect() is *long time* deprecated and the canonical event naming is with dashes: "key-press-event". > static gboolean key_press_win(GtkWidget* w, GdkEventKey* key, gpointer data) { > printf("press.\n"); > > return false; > } > > > I was expecting to see some output on the console, but nothing shows > up. The window does also have mouse click event handlers, which work > fine.... > > Can anyone see what I have done wrong? The drawing area has to have keyboard focus to get keyboard events. Set its "can-focus" property to TRUE. It also has to get the focus somehow, widgets that can have keyboard focus typically grab it with gtk_widget_grab_focus() when one clicks on them with mouse. Yeti -- Anonyms eat their boogers. _______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list