Make text easier to select in hover mode (#18)

This commit is contained in:
Alex Yatskov 2016-10-17 09:01:43 -07:00
parent bc8ef56cc2
commit aa1a2b0176

View File

@ -64,7 +64,7 @@ class Driver {
if (this.enabled && this.lastMousePos !== null && e.keyCode === 16 /* shift */) { if (this.enabled && this.lastMousePos !== null && e.keyCode === 16 /* shift */) {
this.searchAt(this.lastMousePos, true); this.searchAt(this.lastMousePos, true);
} else if (e.keyCode === 27) { } else if (e.keyCode === 27 /* esc */) {
this.hidePopup(); this.hidePopup();
} }
} }
@ -76,13 +76,17 @@ class Driver {
} }
onMouseMove(e) { onMouseMove(e) {
this.lastMousePos = {x: e.clientX, y: e.clientY};
this.popupTimerClear(); this.popupTimerClear();
this.lastMousePos = {x: e.clientX, y: e.clientY};
if (!this.enabled) { if (!this.enabled) {
return; return;
} }
if (e.which === 1 /* lmb */) {
return;
}
if (this.options.holdShiftToScan && !e.shiftKey) { if (this.options.holdShiftToScan && !e.shiftKey) {
return; return;
} }
@ -96,11 +100,9 @@ class Driver {
} }
onMouseDown(e) { onMouseDown(e) {
this.lastMousePos = {x: e.clientX, y: e.clientY}; if (this.popup.visible()) {
if (this.enabled && (e.shiftKey || !this.options.holdShiftToScan || e.which === 2 /* mmb */)) { const selection = window.getSelection();
this.searchAt(this.lastMousePos, true); selection.removeAllRanges();
} else {
this.hidePopup();
} }
} }