Re: key_press_event for drawing area.



Yes, but it's more complicated than you think :-(

You need to arrange for your drawing area to be "focusable", and it
has to be able to indicate to the user that it has the keyboard focus.
You need to subclass drawingarea and implement
size_request/size_allocate (allow space for the focus indicator),
expose_event (draw the focus indicator plus any drawing you do), event
(grab the focus on left-click), set the GTK_CAN_FOCUS flag in init,
and gtk_widget_add_events(GDK_KEY_PRESS_MASK).

Imho, when the focus indicator is not needed or can be handled in the
display of the drawing area itself, you should not need to subclass,
just set CAN_FOCUS and MASK.

Carsten




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