Re: How to know when user pushes Del key ?

Hi Colossus,
You have to connect to the "widget's" key_press_event to check for the
required key...

#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>

g_signal_connect (widget, "key_press_event", G_CALLBACK
(widget_on_key_pressed), <your data>);

gboolean widget_on_key_pressed (GtkWidget* widget, GdkEventKey* event,
gpointer data)
       g_return_val_if_fail (e != NULL, FALSE);
        if (event->keyval == GDK_Backspace) { //put whatever key you wish
              //do something
        return TRUE/FALSE;

if you return TRUE, the signal will not be propogated.. I mean the
default handler(if there is any) for that key will not be called...

You can also refer:

and search for "key_press_event"


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