Re: keypress from a drawing area



"frederik jensen" <frederik_jensen get2net dk> writes:  
> Is there any way to connect the key press event with darea instead
> of the main window?
> 

Your drawing area needs to get the key focus. There are several parts
of this:

  - set the GTK_CAN_FOCUS flag on it with GTK_WIDGET_SET_FLAGS
  - on focus_in_event, set GTK_HAS_FOCUS
  - on focus_out_event, unset GTK_HAS_FOCUS
  - on button_press_event, call gtk_widget_grab_focus()
  - you probably want to draw a focus rectangle while you have the
    focus so users can see you're focused

If you want events regardless of key focus, then you want to connect
to the window, not the drawing area.

Havoc






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