aboutsummaryrefslogtreecommitdiff
path: root/ext/js/language/text-scanner.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-05-19 20:09:37 -0400
committerGitHub <noreply@github.com>2021-05-19 20:09:37 -0400
commit6184bcb812686f5498ee982ae89da88792b9a880 (patch)
treeb64fd9b45fe8909c3c5e553af701e6ae18fc0170 /ext/js/language/text-scanner.js
parenteddd0288643f08d2a2c85f73575bc7ee1c157539 (diff)
Selection clear improvements (#1690)
* Update selection clear process * Clean up old clearSelection API * Update clear order * Add clear event handling
Diffstat (limited to 'ext/js/language/text-scanner.js')
-rw-r--r--ext/js/language/text-scanner.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/ext/js/language/text-scanner.js b/ext/js/language/text-scanner.js
index 2ebf26e2..80887b8e 100644
--- a/ext/js/language/text-scanner.js
+++ b/ext/js/language/text-scanner.js
@@ -139,8 +139,6 @@ class TextScanner extends EventDispatcher {
if (value) {
this._hookEvents();
- } else {
- this.clearSelection(true);
}
}
@@ -259,7 +257,7 @@ class TextScanner extends EventDispatcher {
return (this._textSourceCurrent !== null);
}
- clearSelection(passive) {
+ clearSelection() {
if (!this._canClearSelection) { return; }
if (this._textSourceCurrent !== null) {
if (this._textSourceCurrentSelected) {
@@ -273,7 +271,6 @@ class TextScanner extends EventDispatcher {
this._textSourceCurrentSelected = false;
this._inputInfoCurrent = null;
}
- this.trigger('clearSelection', {passive});
}
getCurrentTextSource() {
@@ -431,7 +428,7 @@ class TextScanner extends EventDispatcher {
case 0: // Primary
if (this._searchOnClick) { this._resetPreventNextClickScan(); }
this._scanTimerClear();
- this.clearSelection(false);
+ this._triggerClear('mousedown');
break;
case 1: // Middle
if (this._preventMiddleMouse) {
@@ -1105,4 +1102,8 @@ class TextScanner extends EventDispatcher {
}
}
}
+
+ _triggerClear(reason) {
+ this.trigger('clear', {reason});
+ }
}