From 2098d2faaeb1658ef753eb9f4ac123698938480e Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 27 Mar 2021 22:30:45 -0400 Subject: 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 --- ext/js/input/hotkey-handler.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ext/js/input') 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(); -- cgit v1.2.3