From 4e778edb278fef27acf6d2234cc7a4903c8d3477 Mon Sep 17 00:00:00 2001 From: jahorton Date: Thu, 26 Mar 2020 21:22:28 +0700 Subject: [PATCH] refactor(web): starts cleanup of mnemonic swallowKeypress use --- web/source/dom/preProcessor.ts | 7 +++++++ web/source/kmwembedded.ts | 2 +- web/source/osk/preProcessor.ts | 4 ++-- web/source/text/processor.ts | 10 ---------- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/web/source/dom/preProcessor.ts b/web/source/dom/preProcessor.ts index 5f4e86b33d..b2d77c5317 100644 --- a/web/source/dom/preProcessor.ts +++ b/web/source/dom/preProcessor.ts @@ -232,6 +232,13 @@ namespace com.keyman.dom { e.preventDefault(); e.stopPropagation(); } + + processor.swallowKeypress = (Levent.Lcode != 8 ? Levent.Lcode != 0 : false); + if(Levent.Lcode == 8) { + processor.swallowKeypress = false; + } + } else { + processor.swallowKeypress = false; } return !LeventMatched; diff --git a/web/source/kmwembedded.ts b/web/source/kmwembedded.ts index 82be48113d..5da04498e4 100644 --- a/web/source/kmwembedded.ts +++ b/web/source/kmwembedded.ts @@ -448,7 +448,7 @@ namespace com.keyman.text { // Now that we have a valid key event, hand it off to the Processor for execution. // This allows the Processor to also handle any predictive-text tasks necessary. - let retVal = com.keyman.osk.PreProcessor.processClick(Lkc, null); + let retVal = com.keyman.osk.PreProcessor.handleClick(Lkc, null); // Special case for embedded to pass K_TAB back to device to process if(Lkc.Lcode == Codes.keyCodes["K_TAB"] || Lkc.Lcode == Codes.keyCodes["K_TABBACK"] diff --git a/web/source/osk/preProcessor.ts b/web/source/osk/preProcessor.ts index c28a825054..bcee44f378 100644 --- a/web/source/osk/preProcessor.ts +++ b/web/source/osk/preProcessor.ts @@ -106,7 +106,7 @@ namespace com.keyman.osk { com.keyman.dom.DOMEventHandlers.states._IgnoreNextSelChange = 0; } - let retVal = PreProcessor.processClick(Lkc, e); + let retVal = PreProcessor.handleClick(Lkc, e); // Now that processing is done, we can do a bit of post-processing, too. keyman.uiManager.setActivatingUI(false); // I2498 - KeymanWeb OSK does not accept clicks in FF when using automatic UI @@ -119,7 +119,7 @@ namespace com.keyman.osk { // Created during refactoring for web-core. Mostly serves to hold DOM-dependent // code that affects both 'native' and 'embedded' mode OSK use after the KeyEvent // object has been properly instantiated. - static processClick(Lkc: text.KeyEvent, e: KeyElement) { + static handleClick(Lkc: text.KeyEvent, e: KeyElement) { let keyman = com.keyman.singleton; // Exclude menu and OSK hide keys from normal click processing if(Lkc.kName == 'K_LOPT' || Lkc.kName == 'K_ROPT') { diff --git a/web/source/text/processor.ts b/web/source/text/processor.ts index d5cd59b64a..c425c1ef17 100644 --- a/web/source/text/processor.ts +++ b/web/source/text/processor.ts @@ -266,8 +266,6 @@ namespace com.keyman.text { e = null as osk.KeyElement; // Cast is necessary for TS type-checking later in the method. } - this.swallowKeypress = false; - // The default OSK layout for desktop devices does not include nextlayer info, relying on modifier detection here. // It's the OSK equivalent to doModifierPress on 'desktop' form factors. if((formFactor == FormFactor.Desktop || this.activeKeyboard.usesDesktopLayoutOnDevice(keyEvent.device)) && fromOSK) { @@ -383,14 +381,6 @@ namespace com.keyman.text { // For DOM-aware targets, this will trigger a DOM event page designers may listen for. outputTarget.doInputEvent(); } - - this.swallowKeypress = (e && keyEvent.Lcode != 8 ? keyEvent.Lcode != 0 : false); - if(keyEvent.Lcode == 8) { - this.swallowKeypress = false; - } - return false; - } else { - this.swallowKeypress = false; } /* I732 END - 13/03/2007 MCD: End Positional Layout support in OSK */