More on keyboard events



Hi!
Continuing with the probelm of override the handling of the Keyboard events by the main window in favour of the focused child widget or not (see thread on archive [1]), I've face the following problem:
When the main window's on_key_press_event is running it has the event key to check.
To decide if the key event should be or not be handled by the main window or let the child focused widget to handle it first, I should know what's the correspondent action currently associated to that event. This can be done retrieving the action map from the main window and doing a search by keyboard event.
The problem comes when the widget has that keyboard event as a built in default shortcut. For example the key 'Page Up' is used by a spin button to increase the value a certain amount. If that shortcut is associated to a action on the main window I would like that the spin button receives the key event first and that it handles the key event. If handled then just return true.
But other times I don't want the widget to handle its own built in keyboard event because the efect it has on the widget is already defined by a custom action.
For example for a tree view, CTRL-A is a built in for select all the rows (if it is allowed) but my application already has an action to select all the rows (all the items of the treeview) that maybe is associated to other different keyboard event. This keyboard event is used ven if the treeview is not focused. There are other treeview (treeview 2) with similar behavior: all the rows (all the items) be selected by a keyboard event even if the tree view is not focused. The problem comes when the treeview2 has CTRL-A as associated keyboard event to select all the items and I'm focusing treeview1, I can never reach action of select all for treeview2 if treeview1 is focused.
So I need to know if a event is going to be handled before effectively call to the widget to handle it and look up the returned value.
Is there a way to know if a event is efectively handled by a widget without effectively perform the action?
Maybe I can create one instance of a widget of the same type than the focused and pass the event to its event handler and see if it returns true or not to know if it is handled by it?
Looks like I replied my self???!! ^___^

Thanks for reading!
Greetings
Carlos

[1] http://mail.gnome.org/archives/gtkmm-list/2012-January/msg00038.html


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