summaryrefslogtreecommitdiff
path: root/ext/js/input/hotkey-handler.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-03-27 22:30:45 -0400
committerGitHub <noreply@github.com>2021-03-27 22:30:45 -0400
commit2098d2faaeb1658ef753eb9f4ac123698938480e (patch)
tree72a92c3c9a2f3de4c6e5419d4e4bda55d5d04c6a /ext/js/input/hotkey-handler.js
parentaf04a4f414ae0a2dce6c46dc30c9fdee119912c2 (diff)
Hotkey arguments (#1565)
* Update display * Move scope definitions * Update scopes button after changing action * Don't show menu if empty * Improve scope updating * Update style * Simplify * Add argument to settings * Update convertToNumber implementation * Add support for arguments * Pass argument to action handler * Update hotkey action definitions * Remove x3 options
Diffstat (limited to 'ext/js/input/hotkey-handler.js')
-rw-r--r--ext/js/input/hotkey-handler.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/js/input/hotkey-handler.js b/ext/js/input/hotkey-handler.js
index d3b82d48..8388302d 100644
--- a/ext/js/input/hotkey-handler.js
+++ b/ext/js/input/hotkey-handler.js
@@ -166,12 +166,12 @@ class HotkeyHandler extends EventDispatcher {
}
_invokeHandlers(modifiers, hotkeyInfo) {
- for (const {modifiers: handlerModifiers, action} of hotkeyInfo.handlers) {
+ for (const {modifiers: handlerModifiers, action, argument} of hotkeyInfo.handlers) {
if (!this._areSame(handlerModifiers, modifiers)) { continue; }
const actionHandler = this._actions.get(action);
if (typeof actionHandler !== 'undefined') {
- const result = actionHandler();
+ const result = actionHandler(argument);
if (result !== false) {
return true;
}
@@ -196,7 +196,7 @@ class HotkeyHandler extends EventDispatcher {
this._hotkeys.clear();
for (const [scope, registrations] of this._hotkeyRegistrations.entries()) {
- for (const {action, key, modifiers, scopes, enabled} of registrations) {
+ for (const {action, argument, key, modifiers, scopes, enabled} of registrations) {
if (!(enabled && key !== null && action !== '' && scopes.includes(scope))) { continue; }
let hotkeyInfo = this._hotkeys.get(key);
@@ -205,7 +205,7 @@ class HotkeyHandler extends EventDispatcher {
this._hotkeys.set(key, hotkeyInfo);
}
- hotkeyInfo.handlers.push({modifiers: new Set(modifiers), action});
+ hotkeyInfo.handlers.push({modifiers: new Set(modifiers), action, argument});
}
}
this._updateEventHandlers();