Re: Key with callback



Hi all,
How can I associate a callback to a key? I would like to press
F10 to launch a process.
Thanks in advance.

These examples should answer your question.
Carlos

------------monitor events----------------
gtk_widget_set[add]_events (GTK_WIDGET (window), GDK_EXPOSURE_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);

--------connect-------------
gtk_signal_connect(GTK_OBJECT (window), "key_press_event",
                   GTK_SIGNAL_FUNC(app_gtk_handle_key_press), data);

--------callback---------------
#include <gdk/gdkkeysyms.h>

gint app_gtk_handle_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data)
{
switch (event->keyval)
  {
  case GDK_Escape:

  case GDK_F2:

  case GDK_F3:

  case GDK_Page_Down:
  }

/* prevent the default handler from being run */
gtk_signal_emit_stop_by_name (GTK_OBJECT(widget),"key_press_event");

return TRUE;
}




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