Skip to content

Commit

Permalink
Move to _inputtingText method
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuuuube committed May 17, 2024
1 parent ce83707 commit d4b83d4
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions ext/js/language/text-scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,7 @@ export class TextScanner extends EventDispatcher {
*/
_onKeyDown(e) {
if (this._lastMouseMove !== null && (e.ctrlKey || e.shiftKey || e.altKey || e.metaKey)) {
const activeElement = document.activeElement;
if (activeElement && activeElement instanceof HTMLElement) {
if (activeElement.nodeName === 'INPUT' || activeElement.nodeName === 'TEXTAREA') { return; }
if (activeElement.isContentEditable) { return; }
}
if (this._inputtingText()) { return; }
const syntheticMouseEvent = new MouseEvent(this._lastMouseMove.type, {
screenX: this._lastMouseMove.screenX,
screenY: this._lastMouseMove.screenY,
Expand All @@ -584,6 +580,18 @@ export class TextScanner extends EventDispatcher {
}
}

/**
* @returns {boolean}
*/
_inputtingText() {
const activeElement = document.activeElement;
if (activeElement && activeElement instanceof HTMLElement) {
if (activeElement.nodeName === 'INPUT' || activeElement.nodeName === 'TEXTAREA') { return true; }
if (activeElement.isContentEditable) { return true; }
}
return false;
}

/**
* @param {MouseEvent} e
* @returns {boolean|void}
Expand Down

0 comments on commit d4b83d4

Please sign in to comment.