Re: [gtk-list] key_press in a drawing area (SOLVED)




Never mind, I figured it out - I needed the following two lines:

GTK_WIDGET_SET_FLAGS (widget_, GTK_CAN_FOCUS);
gtk_widget_grab_focus (widget_);

> From: Dave Reed <dreed@capital.edu>
> 
> I've looked at this for a couple hours and don't see why this doesn't
> work (same idea as the gtk/testinput.c file)
> 
> I've got the following for a drawing_area widget (widget_)
> 
> gtk_widget_set_events (widget_, GDK_EXPOSURE_MASK
> 			 | GDK_LEAVE_NOTIFY_MASK
> 			 | GDK_BUTTON_PRESS_MASK
> 			 | GDK_BUTTON_RELEASE_MASK
> 			 | GDK_BUTTON_MOTION_MASK
> 			 | GDK_POINTER_MOTION_MASK
> 			 | GDK_POINTER_MOTION_HINT_MASK
> 			 | GDK_KEY_PRESS_MASK);
> 
> 
>   gtk_signal_connect (GTK_OBJECT(widget_), "key_press_event",
> 		      (GtkSignalFunc) key_callback, this);
>   gtk_signal_connect (GTK_OBJECT(widget_), "button_press_event",
> 		      (GtkSignalFunc) mouse_callback, this);
> 
> When I press a mouse_button, mouse_callback is called, but when I
> press a key, key_callback is not?
> 
> The drawing area widget is in a window that has accelerators for menu
> items (all using the control key) - could this affect regular key
> presses in the drawing area?  Any ideas why key_callback isn't called
> when I press a key?
> 
> Thanks,
> Dave



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