Re: [gtk-list] Re: Drawing area question




Andrew Pimlott <pimlott@abel.MATH.HARVARD.EDU> writes:

> On 8 Jul 1998, Owen Taylor wrote:
> 
> >  - You need to make sure that the drawing area gets the focus. 
> >    That means:
> >   
> >     GTK_WIDGET_SET_FLAGS (darea, GTK_CAN_FOCUS);
> >     gtk_widget_grab_focus (darea);
> 
> This was very confusing for me the first time, and obviously has stumped
> other as well.  So I must ask, why the redundancy?  If I call
> gtk_widget_grab_focus, isn't it obvious I want the widget to get the focus
> whether I set GTK_CAN_FOCUS or not?  And, doesn't it make sense that if I
> have set GTK_CAN_FOCUS, I expect to get the focus at the appropriate times
> without explicitly asking for it?
> 
> I know there's a good answer based on how X does things (which I'd be
> grateful to hear), but how about a (single) new function that just does
> what most of us expect? 

This has little to do with how X handles things:

 - GTK_WIDGET_SET_FLAGS (darea, GTK_CAN_FOCUS)
  
   Means: this widget will get the focus when the user tabs through.

 - gtk_widget_grab_focus (darea)

   Means: Give this widget the focus _right_now_; the user will
   later be able to tab out.

These are doing conceptually quite different things.  I think having
grab_focus() set the CAN_FOCUS flag when called on a widget without it
set would be quite confusing.

If you want to ignore focusing entirely, then you should, as somebody
mentioned, be trapping key press events on the toplevel window.

Regards,
                                Owen



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