Bug in receiving key_press events



Hi,

If you connect a handler to 'key_press_event' in a window, you get each
key event twice.

(Strangely, if you use 'connect_after' you only get it once.)


Damon



Example source:

#include <gtk/gtk.h>

gint
on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
  g_print("In on_key_press_event EventType:%i Key:%i String:%s\n",
   event->type, event->keyval, event->string);
  return TRUE;
}

int
main(int argc, char *argv[])
{
  GtkWidget *win, *vbox, *scrollbar, *label;

  gtk_init(&argc, &argv);
  win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_usize(win, 300, 150);
  gtk_signal_connect (GTK_OBJECT (win), "key_press_event",
        GTK_SIGNAL_FUNC(on_key_press), NULL);
  gtk_widget_show(win);
  gtk_main();
  return 0;
}






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]