diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-01-17 16:55:45 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-17 16:55:45 -0500 |
commit | 14b4aee07dc3f69ad75518cf04cafe416e06f0c7 (patch) | |
tree | 407918a74817284cd9f1d474a6c7783033e7a4c6 /ext/mixed/js/display.js | |
parent | 8ec48456e6d73e10239469c39e7862365db43739 (diff) |
Hotkey forwarding support (#1263)
* Add support for allowing HotkeyHandler to forward hotkeys
* Update hotkey registration
* Pass HotkeyHandler instance into Display* constructor
* Implement hotkey forwarding
Diffstat (limited to 'ext/mixed/js/display.js')
-rw-r--r-- | ext/mixed/js/display.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index b8baccf9..c3e118c6 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -24,7 +24,6 @@ * DocumentUtil * FrameEndpoint * Frontend - * HotkeyHandler * MediaLoader * PopupFactory * QueryParser @@ -35,11 +34,12 @@ */ class Display extends EventDispatcher { - constructor(pageType, japaneseUtil, documentFocusController) { + constructor(pageType, japaneseUtil, documentFocusController, hotkeyHandler) { super(); this._pageType = pageType; this._japaneseUtil = japaneseUtil; this._documentFocusController = documentFocusController; + this._hotkeyHandler = hotkeyHandler; this._container = document.querySelector('#definitions'); this._definitions = []; this._optionsContext = {depth: 0, url: window.location.href}; @@ -60,7 +60,6 @@ class Display extends EventDispatcher { japaneseUtil, mediaLoader: this._mediaLoader }); - this._hotkeyHandler = new HotkeyHandler(this._pageType); this._messageHandlers = new Map(); this._directMessageHandlers = new Map(); this._windowMessageHandlers = new Map(); @@ -199,7 +198,6 @@ class Display extends EventDispatcher { this._audioSystem.prepare(); this._queryParser.prepare(); this._history.prepare(); - this._hotkeyHandler.prepare(); // Event setup this._history.on('stateChanged', this._onStateChanged.bind(this)); @@ -498,6 +496,9 @@ class Display extends EventDispatcher { this._parentPopupId = parentPopupId; this._parentFrameId = parentFrameId; this._ownerFrameId = ownerFrameId; + if (this._pageType === 'popup') { + this._hotkeyHandler.forwardFrameId = ownerFrameId; + } this._childrenSupported = childrenSupported; this._setContentScale(scale); await this.setOptionsContext(optionsContext); @@ -1879,8 +1880,9 @@ class Display extends EventDispatcher { } _updateHotkeys(options) { - this._hotkeyHandler.clearHotkeys(); - this._hotkeyHandler.registerHotkeys(options.inputs.hotkeys); + const scope = this._pageType; + this._hotkeyHandler.clearHotkeys(scope); + this._hotkeyHandler.registerHotkeys(scope, options.inputs.hotkeys); } async _closeTab() { |