RE: [gtk-list] [?] Handling key_press_events



> Hello,
> I have problems with key_press_event from a drawing area. In the 
> following 
> short program button_press_events are handled as described in the
> tutorial but 'key_press_event' is never called. Any hints what I am doing
> wrong?

(I'm not sure about this but...)

To handle keyboard events you also have to consider the keyboard focus.
I don't think the drawing area widget accepts the keyboard focus by
default. You could possibly set it with:

  GTK_WIDGET_SET_FLAGS (darea, GTK_CAN_FOCUS);

To make the drawing area grab keypresses you can use:

  gtk_widget_grab_focus (darea);

Another, possibly better, alternative is to add the keypress signal
handlers to the window instead.


Damon




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