diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-12-11 21:53:27 -0500 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-12-13 23:11:56 -0500 |
commit | b7144ed879a59b89ee11aa13702e89a6fdaa0e35 (patch) | |
tree | 40ba54d62c21c0208ade259e4c1f0617023bdd04 /ext/fg/js | |
parent | a9c4ce724caf4824b8bb6f6fffe3db4c9dbb7bf6 (diff) |
Update display float key handlers
Diffstat (limited to 'ext/fg/js')
-rw-r--r-- | ext/fg/js/float.js | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index f25dfd73..74bc58b0 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -56,15 +56,14 @@ class DisplayFloat extends Display { onKeyDown(e) { const key = Display.getKeyFromEvent(e); - const handlers = DisplayFloat.onKeyDownHandlers; - if (hasOwn(handlers, key)) { - const handler = handlers[key]; + const handler = DisplayFloat._onKeyDownHandlers.get(key); + if (typeof handler === 'function') { if (handler(this, e)) { e.preventDefault(); - return; + return true; } } - super.onKeyDown(e); + return super.onKeyDown(e); } getOptionsContext() { @@ -96,15 +95,15 @@ class DisplayFloat extends Display { } } -DisplayFloat.onKeyDownHandlers = { - 'C': (self, e) => { +DisplayFloat._onKeyDownHandlers = new Map([ + ['C', (self, e) => { if (e.ctrlKey && !window.getSelection().toString()) { self.onSelectionCopy(); return true; } return false; - } -}; + }] +]); DisplayFloat._messageHandlers = new Map([ ['setContent', (self, {type, details}) => self.setContent(type, details)], |