From 405e487a7347181f6f49f01839c807c84fc93e41 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Fri, 31 Mar 2017 21:48:10 -0700 Subject: ctrl + c to copy --- ext/fg/js/display-frame.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'ext/fg/js/display-frame.js') diff --git a/ext/fg/js/display-frame.js b/ext/fg/js/display-frame.js index 59032d0c..f6f7683e 100644 --- a/ext/fg/js/display-frame.js +++ b/ext/fg/js/display-frame.js @@ -51,6 +51,10 @@ window.displayFrame = new class extends Display { window.parent.postMessage('popupClose', '*'); } + selectionCopy() { + window.parent.postMessage('selectionCopy', '*'); + } + showOrphaned() { $('#content').hide(); $('#orphan').show(); @@ -77,4 +81,27 @@ window.displayFrame = new class extends Display { handler(params); } } + + onKeyDown(e) { + if (super.onKeyDown(e)) { + return true; + } + + const handlers = { + 67: /* c */ () => { + if (e.ctrlKey) { + this.selectionCopy(); + return true; + } + } + }; + + const handler = handlers[e.keyCode]; + if (handler && handler()) { + e.preventDefault(); + return true; + } + + return false; + } }; -- cgit v1.2.3 From f556c95038e2ef9e4d97b4168ce417ba0d74282f Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 1 Apr 2017 11:20:58 -0700 Subject: improve ctrl + c behavior --- ext/fg/js/display-frame.js | 11 +++-------- ext/mixed/js/display.js | 3 --- 2 files changed, 3 insertions(+), 11 deletions(-) (limited to 'ext/fg/js/display-frame.js') diff --git a/ext/fg/js/display-frame.js b/ext/fg/js/display-frame.js index f6f7683e..9fd09e74 100644 --- a/ext/fg/js/display-frame.js +++ b/ext/fg/js/display-frame.js @@ -83,13 +83,9 @@ window.displayFrame = new class extends Display { } onKeyDown(e) { - if (super.onKeyDown(e)) { - return true; - } - const handlers = { 67: /* c */ () => { - if (e.ctrlKey) { + if (e.ctrlKey && window.getSelection().toString() === '') { this.selectionCopy(); return true; } @@ -99,9 +95,8 @@ window.displayFrame = new class extends Display { const handler = handlers[e.keyCode]; if (handler && handler()) { e.preventDefault(); - return true; + } else { + super.onKeyDown(e); } - - return false; } }; diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index f950f0f0..9738319a 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -301,10 +301,7 @@ class Display { const handler = handlers[e.keyCode]; if (handler && handler()) { e.preventDefault(); - return true; } - - return false; } sourceBack() { -- cgit v1.2.3