Re: Geting an drawing area to recieve key events



Nuno Afonso wrote:

> On Wed, 2001-12-12 at 00:53, Norman Black wrote:
> 
>>>>does anyone know how to make an drawing area to recieve the key events?
>>>>
>>>gtk_widget_set_events(area, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK)
>>>
>>You also need to make sure it has the GTK_CAN_FOCUS flags.
>>
> 
> i tried this but it didn't work, the parent widget is the one that gets
> the keyboard inputs.


I think to get this working nicely, you need to integrate your drawing 
area into the gtk focus model. The best way to do this (I think) is to 
subclass drawingarea, and implement:

   widget->focus_in_event
   widget->focus_out_event
   widget->draw_focus (so the user knows when your drawing area has the 
keyboard focus)

also intercept button_press and do a grab_focus.

It's easier than it sounds, take a look at gtkbutton.c and chop the code 
around.

I could probably make you some code if you get stuck.

John




========================================================== 
Renaissance Autumn at the National Gallery 
A season of exhibitions, displays and events with a Renaissance theme. 

Pisanello: Painter to the Renaissance Court (24 October - 13 January 2002) 

For information and tickets: 
http://www.nationalgallery.org.uk/what/news/ren_autumn.htm



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