Re: [gtk-list] GtkEntry specific accelerators



Sean Christopher Rhea wrote:

> 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
> http://www.ece.utexas.edu/~srhea

Connect the "key_press_event" of the entry widget to an event-handler of
your own. Inside the handler you can do what you want.

Simple

  gtk_signal_connect(GTK_OBJECT(entryw), "key_press_event",
       GTK_SIGNAL_FUNC(entry_key_event), NULL);

and

static gint editl_key_event(GtkWidget* widget,
       GdkEventKey* event,
       gpointer   data){
gint key=event->keyval;
[...]
}

To get the meaning of "key", look at gdkkeysyms.h

    Jan Kellmer



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