diff --git a/common/web/keyboard-processor/src/text/kbdInterface.ts b/common/web/keyboard-processor/src/text/kbdInterface.ts index cd50d7fd12..672ecd4ded 100644 --- a/common/web/keyboard-processor/src/text/kbdInterface.ts +++ b/common/web/keyboard-processor/src/text/kbdInterface.ts @@ -921,7 +921,8 @@ namespace com.keyman.text { */ setStore(systemId: number, strValue: string, outputTarget: OutputTarget): boolean { this.resetContextCache(); - if(systemId == KeyboardInterface.TSS_LAYER) { + // Unique case: we only allow set(&layer) ops from keyboard rules triggered by touch OSKs. + if(systemId == KeyboardInterface.TSS_LAYER && this.activeDevice.touchable) { // Denote the changed store as part of the matched rule's behavior. this.ruleBehavior.setStore[systemId] = strValue; } else { diff --git a/common/web/keyboard-processor/src/text/keyboardProcessor.ts b/common/web/keyboard-processor/src/text/keyboardProcessor.ts index 6eddc09c33..bb4513f35e 100644 --- a/common/web/keyboard-processor/src/text/keyboardProcessor.ts +++ b/common/web/keyboard-processor/src/text/keyboardProcessor.ts @@ -731,7 +731,7 @@ namespace com.keyman.text { } else if(KeyboardProcessor.isModifier(Levent)) { this.activeKeyboard.notify(Levent.Lcode, outputTarget, isKeyDown ? 1 : 0); // For eventual integration - we bypass an OSK update for physical keystrokes when in touch mode. - if(!Levent.device.touchable) { + if(!this.contextDevice.touchable) { return this._UpdateVKShift(Levent); // I2187 } else { return true; @@ -740,7 +740,9 @@ namespace com.keyman.text { if(Levent.LmodifierChange) { this.activeKeyboard.notify(0, outputTarget, 1); - this._UpdateVKShift(Levent); + if(!this.contextDevice.touchable) { + this._UpdateVKShift(Levent); + } } // No modifier keypresses detected. @@ -750,7 +752,9 @@ namespace com.keyman.text { resetContext() { this.layerId = 'default'; this.keyboardInterface.resetContextCache(); - this._UpdateVKShift(null); + if(!this.contextDevice.touchable) { + this._UpdateVKShift(null); + } }; setNumericLayer(device: utils.DeviceSpec) { diff --git a/web/source/keymanweb.ts b/web/source/keymanweb.ts index 61d523f6fa..88cef3e2b1 100644 --- a/web/source/keymanweb.ts +++ b/web/source/keymanweb.ts @@ -117,20 +117,9 @@ if(!window['keyman']['initialized']) { util.attachDOMEvent(document, 'keyup', keymanweb.hotkeyManager._Process, false); - /** - * Reset OSK shift states when entering or exiting the active element - **/ - function resetVKShift() { - let keyman = com.keyman.singleton; - if(!keyman.uiManager.isActivating && keyman.osk?.vkbd) { - keyman.core.keyboardProcessor._UpdateVKShift(null); //this should be enabled !!!!! TODO - } - } - // We need to track this handler, as it causes... interesting... interactions during testing in certain browsers. - keymanweb['pageFocusHandler'] = resetVKShift; - util.attachDOMEvent(window, 'focus', keymanweb['pageFocusHandler'], false); // I775 - util.attachDOMEvent(window, 'blur', keymanweb['pageFocusHandler'], false); // I775 + util.attachDOMEvent(window, 'focus', keymanweb.pageFocusHandler, false); // I775 + util.attachDOMEvent(window, 'blur', keymanweb.pageFocusHandler, false); // I775 // Initialize supplementary plane string extensions String.kmwEnableSupplementaryPlane(true); diff --git a/web/source/kmwbase.ts b/web/source/kmwbase.ts index 71414c5efc..d1ccd15c6a 100644 --- a/web/source/kmwbase.ts +++ b/web/source/kmwbase.ts @@ -176,6 +176,17 @@ namespace com.keyman { this.touchAliasing = this.util.device.touchable ? this.domManager.touchHandlers : this.domManager.nonTouchHandlers; } + /** + * Reset context when entering or exiting the active element. + * Will also trigger OSK shift state / layer reset. + **/ + pageFocusHandler = () => { + if(!this.uiManager.isActivating && this.osk?.vkbd) { + this.core.resetContext(null); + } + return false; + } + /** * Triggers a KeymanWeb engine shutdown to facilitate a full system reset. * This function is designed for use with KMW unit-testing, which reloads KMW @@ -183,8 +194,8 @@ namespace com.keyman { */ ['shutdown']() { // Disable page focus/blur events, which can sometimes trigger and cause parallel KMW instances in testing. - this.util.detachDOMEvent(window, 'focus', this['pageFocusHandler'], false); - this.util.detachDOMEvent(window, 'blur', this['pageFocusHandler'], false); + this.util.detachDOMEvent(window, 'focus', this.pageFocusHandler, false); + this.util.detachDOMEvent(window, 'blur', this.pageFocusHandler, false); this.domManager.shutdown(); this.osk.shutdown();