Re: key input get grab by other widget



ehml wrote:
> In the drawing-area, I assign "key press event" to it. It work find for
key
> like "a" and "b", but does not work for arrow key. Once I press a arrow
key,
> the "check button" grab that input, and subsequently, all key is grab by
the
> "check button". The same will happen if I point at the menu-bar and click
in a
> empty space following by pressing a key. What I need is:
> 
> If the pointer is in the drawing-area, drawing-area should grab all key
event.

Hi again :) the problem is that GtkDrawingArea does not implement any of 
the focus stuff that other widgets have (eg. drawing a focus highlight, 
catching focus_in/_out events, etc.).

This means that keyboard input to a drawing area does not work well, 
especially if you mix drawing areas and widgets with "real" keyboard 
handling.

I think the best solution is to subclass drawing area and implement the 
gtk focus system. It's not actually that hard ... when I did this I 
think I read gtkbutton and based it on that code. As I recall, you just 
need to implement

draw_focus
focus_in_event
focus_out_event
button_press_event
button_release_event
expose (you need to add code to draw the focus indicator)

John



========================================================== 
Aelbert Cuyp 13 February - 12 May 2002 

For information and tickets: 
http://www.nationalgallery.org.uk



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