From 618a3cb319c247c7196b1b83389d5f43241ab0c6 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Thu, 25 May 2017 20:56:08 -0700 Subject: support variable modifier keys, fixes #5 --- ext/fg/js/driver.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js index bdcc01b3..b0cc4613 100644 --- a/ext/fg/js/driver.js +++ b/ext/fg/js/driver.js @@ -70,15 +70,22 @@ window.driver = new class { return; } - if (this.options.scanning.requireShift && !e.shiftKey && !(this.mouseDownMiddle && this.options.scanning.middleMouse)) { + const mouseScan = this.mouseDownMiddle && this.options.scanning.middleMouse; + const keyScan = + this.options.scanning.modifier === 'alt' && e.altKey || + this.options.scanning.modifier === 'ctrl' && e.ctrlKey || + this.options.scanning.modifier === 'shift' && e.shiftKey || + this.options.scanning.modifier === 'none'; + + if (!keyScan && !mouseScan) { return; } const searchFunc = () => this.searchAt(this.lastMousePos); - if (this.options.scanning.requireShift) { - searchFunc(); - } else { + if (this.options.scanning.modifier === 'none') { this.popupTimerSet(searchFunc); + } else { + searchFunc(); } } @@ -232,7 +239,7 @@ window.driver = new class { handleError(error, textSource) { if (window.orphaned) { - if (textSource && this.options.scanning.requireShift) { + if (textSource && this.options.scanning.modifier !== 'none') { this.popup.showOrphaned(textSource.getRect(), this.options); } } else { -- cgit v1.2.3