focus questions



I'm including a bunch of question in one message 'cause I'm confused and I
can't find the source.

I basically want a drawing_area to receive key_press events. True of
false: I need

1. GTK_WIDGET_SET_FLAGS (myDrawingArea, GTK_CAN_FOCUS);
2. gtk_widget_grab_focus(myDrawingArea);
3. gtk_signal_connect(GTK_OBJECT(myDrawingArea), "key_press_event",
                      GTK_SIGNAL_FUNC(myOnKeyPress), this);

However, this raises a few questions in my mind.
a. Is it correct to think that only one widget *per window* has focus at
one time?
b. If the window loses focus and gets it back, the same child widget will
have focus?
c. The command 2. will generate a focus_in event?
d. Is this bad design? Is it better to have the window capture the
key_events and somehow redistribute them?

I know I could experiment but it's so much easier to ask (and the
respondent usually go outside the question, too :)

Thanks!

Pavel






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