aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mixed')
-rw-r--r--ext/mixed/js/display.js3
-rw-r--r--ext/mixed/js/text-scanner.js21
2 files changed, 19 insertions, 5 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index e5f12a1a..c7ad8894 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -251,7 +251,8 @@ class Display extends EventDispatcher {
pointerEventsEnabled: scanning.pointerEventsEnabled,
scanLength: scanning.length,
sentenceExtent: options.anki.sentenceExt,
- layoutAwareScan: scanning.layoutAwareScan
+ layoutAwareScan: scanning.layoutAwareScan,
+ preventMiddleMouse: scanning.preventMiddleMouse.onSearchQuery
}
});
}
diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js
index aacc683a..b8d4faf5 100644
--- a/ext/mixed/js/text-scanner.js
+++ b/ext/mixed/js/text-scanner.js
@@ -49,6 +49,7 @@ class TextScanner extends EventDispatcher {
this._scanLength = 1;
this._sentenceExtent = 1;
this._layoutAwareScan = false;
+ this._preventMiddleMouse = false;
this._inputs = [];
this._enabled = false;
@@ -113,7 +114,7 @@ class TextScanner extends EventDispatcher {
}
}
- setOptions({inputs, deepContentScan, selectText, delay, touchInputEnabled, pointerEventsEnabled, scanLength, sentenceExtent, layoutAwareScan}) {
+ setOptions({inputs, deepContentScan, selectText, delay, touchInputEnabled, pointerEventsEnabled, scanLength, sentenceExtent, layoutAwareScan, preventMiddleMouse}) {
if (Array.isArray(inputs)) {
this._inputs = inputs.map(({
include,
@@ -151,6 +152,9 @@ class TextScanner extends EventDispatcher {
if (typeof layoutAwareScan === 'boolean') {
this._layoutAwareScan = layoutAwareScan;
}
+ if (typeof preventMiddleMouse === 'boolean') {
+ this._preventMiddleMouse = preventMiddleMouse;
+ }
}
getTextSourceContent(textSource, length, layoutAwareScan) {
@@ -282,9 +286,18 @@ class TextScanner extends EventDispatcher {
return false;
}
- if (e.button === 0) { // Primary
- this._scanTimerClear();
- this.clearSelection(false);
+ switch (e.button) {
+ case 0: // Primary
+ this._scanTimerClear();
+ this.clearSelection(false);
+ break;
+ case 1: // Middle
+ if (this._preventMiddleMouse) {
+ e.preventDefault();
+ e.stopPropagation();
+ return false;
+ }
+ break;
}
}