Re: How to connect "focus-out-event" of a grid?



Yeti,

Thank you. The purpose is when the focus is moved out of the container, I'll destroy the container and its child widgets. How can I achieve this?

Thanks,
Gang


2014-07-16 15:18 GMT+08:00 David Nečas <yeti physics muni cz>:
On Wed, Jul 16, 2014 at 11:49:52AM +0800, Gang Chen wrote:
> A grid contains an entry and several buttons. I connected my callback
> function to "focus-out-event" of the grid. But no focus-out-event was
> received even if I called gtk_widget_add_events(grid,
> GDK_FOCUS_CHANGE_MASK). I tried to put the grid in an event box and
> connected the callback to "focus-out-event" of the event box. Still no
> focus-out-event was received. Could anybody please help me?

"focus-out-event" is emitted when a widget that can take keyboard focus
loses the focus.  It makes no sense for containers to have keyboard focus
because they do not take input from keyboard.  A particular input widget
inside the container should have the focus.

You can make an event box to take keyboard focus using
gtk_widget_set_can_focus() but this is useless.  It will prevent the
user from tabbing to the child widgets of the event box.  Instead he
will be able to tab to the event box which will look to him like
mysteriously losing focus because the event box is not an input widget.

So just connect to signals of the actual input widgets.

Yeti




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