diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-03-27 22:30:45 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-27 22:30:45 -0400 |
commit | 2098d2faaeb1658ef753eb9f4ac123698938480e (patch) | |
tree | 72a92c3c9a2f3de4c6e5419d4e4bda55d5d04c6a /ext/js/display/display.js | |
parent | af04a4f414ae0a2dce6c46dc30c9fdee119912c2 (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/display/display.js')
-rw-r--r-- | ext/js/display/display.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/ext/js/display/display.js b/ext/js/display/display.js index 7cc3b437..b0805aca 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -115,10 +115,8 @@ class Display extends EventDispatcher { this._hotkeyHandler.registerActions([ ['close', () => { this._onHotkeyClose(); }], - ['nextEntry', () => { this._focusEntry(this._index + 1, true); }], - ['nextEntry3', () => { this._focusEntry(this._index + 3, true); }], - ['previousEntry', () => { this._focusEntry(this._index - 1, true); }], - ['previousEntry3', () => { this._focusEntry(this._index - 3, true); }], + ['nextEntry', this._onHotkeyActionMoveRelative.bind(this, 1)], + ['previousEntry', this._onHotkeyActionMoveRelative.bind(this, -1)], ['lastEntry', () => { this._focusEntry(this._definitions.length - 1, true); }], ['firstEntry', () => { this._focusEntry(0, true); }], ['historyBackward', () => { this._sourceTermView(); }], @@ -1825,6 +1823,13 @@ class Display extends EventDispatcher { this.close(); } + _onHotkeyActionMoveRelative(sign, argument) { + let count = Number.parseInt(argument, 10); + if (!Number.isFinite(count)) { count = 1; } + count = Math.max(0, Math.floor(count)); + this._focusEntry(this._index + count * sign, true); + } + _closeAllPopupMenus() { for (const popupMenu of PopupMenu.openMenus) { popupMenu.close(); |