Yeah! FInally it works!
My top level Gtk::Window is called ToolBox: class
Toolbox : public Gtk::Window so I added the signal
connections as you mentioned, in the constructor:
signal_key_press_event().connect(sigc::mem_fun(*this,
&Toolbox::on_key_press_event), false);
signal_key_release_event().connect(sigc::mem_fun(*this,
&Toolbox::on_key_release_event), false);
The ToolBox only has one member instance of class
Widget_Distance: public Gtk::SpinButton.
This is one of the widgets where I want to stop the
event propagation.
So I added two members to the Widget_Distance to
handle the press and release key events:
bool
Widget_Distance::on_key_press_event(GdkEventKey*
event)
{
return SpinButton::on_key_press_event(event);
}
bool
Widget_Distance::on_key_release_event(GdkEventKey*
event)
{
return SpinButton::on_key_release_event(event);
}
It calls the SpinButton event handlers, so when the
SpinButton doesn't handle the event (false) then it returns
the same value.
Then I added the two other event handlers needed in
the ToolBox:
bool
Toolbox::on_key_press_event(GdkEventKey* event)
{
if(widget_defaults->get_widget_bline_width()->is_focus())
return
widget_defaults->get_widget_bline_width()->on_key_press_event(event);
return Gtk::Window::on_key_press_event(event);
}
bool
Toolbox::on_key_release_event(GdkEventKey* event)
{
if(widget_defaults->get_widget_bline_width()->is_focus())
return
widget_defaults->get_widget_bline_width()->on_key_release_event(event);
return Gtk::Window::on_key_release_event(event);
}
Notice that I first lookup if the widget_bline_width (which
is a instance of a Widget_Distance class) is focus. When it is
focus it is being edited so I don't want to handle the key
events if the widget already handled. So if Widget_Distance
handler returns false then the event is propagated away and it
is cached by the defined Accelerators. If the Widget_Distance
handler returns true the key event doesn't need other handler
and its propagation is stopped.
Now, if the Widget_Distance is not on focus, the Toolbox
key event handler will as to the Gtk::Window for the handling
occurring the same things.
Thank you very much for the explanations to you all.
One final question: the 'after' parameter in the connect
member is documented? if so, where is it?
Greetings
Carlos