From be590004fee5bbbbaefa8a11ddecdb4fca6f7da7 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 17 Jan 2021 11:43:05 -0500 Subject: Text scanner improvements (#1261) * Add support for allowing TextScanner.search to force focus * Simplify query parser searched event forwarding * Defer fallback creation * Simplify event listeners * Change type to pointerType * Change cause to eventType * Change empty to passive; make .search function passive * Remove unused input index --- ext/fg/js/frontend.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ext/fg') diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 8b2df1b0..d789c4f0 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -251,12 +251,12 @@ class Frontend { } } - _onSearched({type, definitions, sentence, inputInfo: {cause, empty}, textSource, optionsContext, detail: {documentTitle}, error}) { + _onSearched({type, definitions, sentence, inputInfo: {eventType, passive, detail}, textSource, optionsContext, detail: {documentTitle}, error}) { const scanningOptions = this._options.scanning; if (error !== null) { if (yomichan.isExtensionUnloaded) { - if (textSource !== null && !empty) { + if (textSource !== null && !passive) { this._showExtensionUnloaded(textSource); } } else { @@ -264,7 +264,11 @@ class Frontend { } } if (type !== null) { this._stopClearSelectionDelayed(); - const focus = (cause === 'mouseMove'); + let focus = (eventType === 'mouseMove'); + if (isObject(detail)) { + const focus2 = detail.focus; + if (typeof focus2 === 'boolean') { focus = focus2; } + } this._showContent(textSource, focus, definitions, type, sentence, documentTitle, optionsContext); } else { if (scanningOptions.autoHideResults) { -- cgit v1.2.3