From aa1a2b01763aab7e0880ec20f8c05bdd11e94c5d Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 17 Oct 2016 09:01:43 -0700 Subject: [PATCH] Make text easier to select in hover mode (#18) --- ext/fg/js/driver.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js index 315a3be6..f1a0be9f 100644 --- a/ext/fg/js/driver.js +++ b/ext/fg/js/driver.js @@ -64,7 +64,7 @@ class Driver { if (this.enabled && this.lastMousePos !== null && e.keyCode === 16 /* shift */) { this.searchAt(this.lastMousePos, true); - } else if (e.keyCode === 27) { + } else if (e.keyCode === 27 /* esc */) { this.hidePopup(); } } @@ -76,13 +76,17 @@ class Driver { } onMouseMove(e) { + this.lastMousePos = {x: e.clientX, y: e.clientY}; this.popupTimerClear(); - this.lastMousePos = {x: e.clientX, y: e.clientY}; if (!this.enabled) { return; } + if (e.which === 1 /* lmb */) { + return; + } + if (this.options.holdShiftToScan && !e.shiftKey) { return; } @@ -96,11 +100,9 @@ class Driver { } onMouseDown(e) { - this.lastMousePos = {x: e.clientX, y: e.clientY}; - if (this.enabled && (e.shiftKey || !this.options.holdShiftToScan || e.which === 2 /* mmb */)) { - this.searchAt(this.lastMousePos, true); - } else { - this.hidePopup(); + if (this.popup.visible()) { + const selection = window.getSelection(); + selection.removeAllRanges(); } }