The Birdfont Source Code
Consume key strokes in key bindings
These changes was commited to the Birdfont repository Mon, 13 Jun 2016 15:29:31 +0000.
Contributing
Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
Consume key strokes in key bindings
--- a/libbirdfont/AbstractMenu.vala
+++ b/libbirdfont/AbstractMenu.vala
@@ -75,7 +75,8 @@
return null;
}
- public void process_key_binding_events (uint keyval) {
+ /** @return true if the keybindings consumes the event. */
+ public bool process_key_binding_events (uint keyval) {
string display;
FontDisplay current_display = MainWindow.get_current_display ();
ToolItem tm;
@@ -96,7 +97,7 @@
if (!SettingsDisplay.update_key_bindings
&& !(item is ToolItem)) {
item.action ();
- return;
+ return true;
}
if (item is ToolItem) {
@@ -106,16 +107,18 @@
if (tm.tool.editor_events) {
MainWindow.get_toolbox ().set_current_tool (tm.tool);
tm.tool.select_action (tm.tool);
- return;
+ return true;
} else {
tm.tool.select_action (tm.tool);
- return;
+ return true;
}
}
}
}
}
}
+
+ return false;
}
public void load_key_bindings () {
--- a/libbirdfont/TabContent.vala
+++ b/libbirdfont/TabContent.vala
@@ -144,8 +144,12 @@
KeyBindings.add_modifier_from_keyval (keyval);
if (!text_input_visible) {
- MainWindow.get_menu ().process_key_binding_events (keyval);
- GlyphCanvas.current_display.key_press (keyval);
+ AbstractMenu menu = MainWindow.get_menu ();
+ bool consumed = menu.process_key_binding_events (keyval);
+
+ if (!consumed) {
+ GlyphCanvas.current_display.key_press (keyval);
+ }
} else {
text_input.key_press (keyval);
}