From f76a6ff1e320646098620a6109919ddb8dbcf747 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 8 Jul 2020 20:02:20 -0400 Subject: Refactor hotkey definitions to be more generic (#655) --- ext/fg/js/float.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index 17af03d3..2debdeff 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -40,14 +40,11 @@ class DisplayFloat extends Display { ['setContentScale', {handler: this._onMessageSetContentScale.bind(this)}] ]); - this.setOnKeyDownHandlers([ - ['C', (e) => { - if (e.ctrlKey && !window.getSelection().toString()) { - this._copySelection(); - return true; - } - return false; - }] + this.registerActions([ + ['copy-host-selection', () => this._copySelection()] + ]); + this.registerHotkeys([ + {key: 'C', modifiers: ['ctrl'], action: 'copy-host-selection'} ]); } @@ -168,7 +165,9 @@ class DisplayFloat extends Display { // Private _copySelection() { + if (window.getSelection().toString()) { return false; } this._invoke('copySelection'); + return true; } _clearAutoPlayTimer() { -- cgit v1.2.3