Re: EventBox doesn't emit Key Events.



En/na Sergio Perticone ha escrit:
> On Tue, 2007-10-30 at 11:50 +0100, Joaquim Duran wrote:
>> Dear All,
>>
>> I'm interested in capture the key press event emitted by an Event Box
>> container.
>>
>> I've modified the eventbox sample included in the GTKmm box to accept
>> button pressed events and key pressed events. The result is the button
>> pressed events are emitted (the window is closed), but not the key
>> pressed events (the window is not closed).
>>
>> I've no idea if I'm doing something wrong or if this is a bug from the
>> library.
>>
>> Gtkmm: 2.12.1
>> Gtk: 2.12.1
>> Glib: 2.14.2
>>
>> Thanks in advance.
>>
>> Thanks and Best Regards,
>> Joaquim Duran
> 
> I use Window to catch that event... so:
> 
> ExampleWindow::ExampleWindow()
> {
>     // ... 
>  
>   set_events(Gdk::KEY_PRESS_MASK);
> 
>   signal_key_press_event().connect(
>       sigc::mem_fun(*this, &ExampleWindow::on_key_press) );
> 
>    // ...
> }
> 
> bool ExampleWindow::on_key_press(GdkEventKey* ev)
> {
>     if (ev->keyval == GDK_Escape)
>         hide();
>     else
>         return false;
> }
> 


Hello,

This is an option, but it is not feasible because this behavior should
be used in several elements of the GUI and they aren't going to close
the main window.

I'm not sure but, for what I've seen show gtkmm behaves, I think that
the key events are not working because there is no widget inside the
event box that gets focus. This is different that maintaining a
reference to the widget that has be mouse pointer over.

The key events are delivered in this way:

Window -> widget with focus -> container of widget -> container of
container of widget -> .... -> container contained directly by window.

Could someone confirm this?

Thanks and Best Regards,
Joaquim Duran



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