summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/fg/js/frontend.js40
-rw-r--r--ext/mixed/js/display.js4
2 files changed, 28 insertions, 16 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index e67008df..7c62b51b 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -80,7 +80,7 @@ class Frontend {
onMouseMove(e) {
this.popupTimerClear();
- if (this.pendingLookup || Frontend.isMouseButton('primary', e)) {
+ if (this.pendingLookup || Frontend.isMouseButtonDown('primary', e)) {
return;
}
@@ -88,7 +88,7 @@ class Frontend {
const scanningModifier = scanningOptions.modifier;
if (!(
Frontend.isScanningModifierPressed(scanningModifier, e) ||
- (scanningOptions.middleMouse && Frontend.isMouseButton('auxiliary', e))
+ (scanningOptions.middleMouse && Frontend.isMouseButtonDown('auxiliary', e))
)) {
return;
}
@@ -504,18 +504,30 @@ class Frontend {
switch (mouseEvent.type) {
case 'mouseup':
case 'mousedown':
- case 'click': switch (button) {
- case 'primary': return mouseEvent.button === 0;
- case 'secondary': return mouseEvent.button === 2;
- case 'auxiliary': return mouseEvent.button === 1;
- default: return false;
- }
- default: switch (button) {
- case 'primary': return (mouseEvent.buttons & 0x1) !== 0x0;
- case 'secondary': return (mouseEvent.buttons & 0x2) !== 0x0;
- case 'auxiliary': return (mouseEvent.buttons & 0x4) !== 0x0;
- default: return false;
- }
+ case 'click':
+ return Frontend.isMouseButtonPressed(button, mouseEvent);
+ default:
+ return Frontend.isMouseButtonDown(button, mouseEvent);
+ }
+ }
+
+ static isMouseButtonPressed(button, mouseEvent) {
+ const mouseEventButton = mouseEvent.button;
+ switch (button) {
+ case 'primary': return mouseEventButton === 0;
+ case 'secondary': return mouseEventButton === 2;
+ case 'auxiliary': return mouseEventButton === 1;
+ default: return false;
+ }
+ }
+
+ static isMouseButtonDown(button, mouseEvent) {
+ const mouseEventButtons = mouseEvent.buttons;
+ switch (button) {
+ case 'primary': return (mouseEventButtons & 0x1) !== 0x0;
+ case 'secondary': return (mouseEventButtons & 0x2) !== 0x0;
+ case 'auxiliary': return (mouseEventButtons & 0x4) !== 0x0;
+ default: return false;
}
}
}
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 5a824561..801011df 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -83,7 +83,7 @@ class Display {
}
onGlossaryMouseDown(e) {
- if (Frontend.isMouseButton('primary', e)) {
+ if (Frontend.isMouseButtonPressed('primary', e)) {
this.clickScanPrevent = false;
}
}
@@ -93,7 +93,7 @@ class Display {
}
onGlossaryMouseUp(e) {
- if (!this.clickScanPrevent && Frontend.isMouseButton('primary', e)) {
+ if (!this.clickScanPrevent && Frontend.isMouseButtonPressed('primary', e)) {
this.onTermLookup(e);
}
}