RE: [gtk-list] GtkEntry specific accelerators

You attach a call back func to the "key_press_event" on the entry widget you
want to make this happen to.  i.e.

#include <gdk/gdkkeysyms.h>

        entry = gtk_entry_new ();
        gtk_signal_connect (GTK_OBJECT (entry), "key_press_event",
                GTK_SIGNAL_FUNC (plus_handler), NULL);

plus_handler (GtkWidget *w, GtkEventKey *ev, gpointer p)
        guint keyval = ev->keyval;

        /* look in /usr/include/gdk/gdkkeysyms.h for other
         * key values */
        if (keyval == GDK_plus)

                /* stop the event, we've already handled it */
                gtk_signal_emit_stop_by_name (GTK_OBJECT (w),
                return 1;

        /* let gtk handle it */
        return 0;

According to Sean Christopher Rhea:
| If I want to catch a specific key only when the focus is in a specific
| GtkEntry, is there a convenient way to do this?  I have a GtkEntry for a
| number, and when '+' is pressed, I want the number incremented instead of
| a '+' being entered in the field.
| Sean C. Rhea

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