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

Re: focus questions



Thanks! Another one. How do I prevent the window (within which my widgets
are) from getting the signal. For instance, I want to use the arrow to
move something but instead focus shifts to another widget.

Pavel


On Fri, 22 Dec 2000, Mark Leisher wrote:

> 
>     Pavel> 1. GTK_WIDGET_SET_FLAGS (myDrawingArea, GTK_CAN_FOCUS);
>     Pavel> 2. gtk_widget_grab_focus(myDrawingArea);
>     Pavel> 3. gtk_signal_connect(GTK_OBJECT(myDrawingArea), "key_press_event",
>     Pavel> GTK_SIGNAL_FUNC(myOnKeyPress), this);
> 
> True.
> 
>     Pavel> However, this raises a few questions in my mind.  a. Is it correct
>     Pavel> to think that only one widget *per window* has focus at one time?
>     Pavel> b. If the window loses focus and gets it back, the same child
>     Pavel> widget will have focus?  c. The command 2. will generate a focus_in
>     Pavel> event?  d. Is this bad design? Is it better to have the window
>     Pavel> capture the key_events and somehow redistribute them?
> 
> The mouse pointer leaving and entering a window generally does not change
> focus, it simply causes enter_notify_event and leave_notify_event signals.
> 
> In your "myOnKeyPress" signal handler, if you use a keypress, return TRUE to
> indicate it was used.  Otherwise return FALSE so it can be passed along to any
> other object that might need it.
> 
>     Pavel> I know I could experiment but it's so much easier to ask (and the
>     Pavel> respondent usually go outside the question, too :)
> 
> The easy questions will get answers, the hard ones won't.  Once you are more
> familiar with GTK, you will find you have to experiment to get answers :-)
> -----------------------------------------------------------------------------
> Mark Leisher
> Computing Research Lab            Cinema, radio, television, magazines are a
> New Mexico State University       school of inattention: people look without
> Box 30001, Dept. 3CRL             seeing, listen without hearing.
> Las Cruces, NM  88003                            -- Robert Bresson
> 
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 





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