diff --git a/web/source/keyboards/keyboard.ts b/web/source/keyboards/keyboard.ts index 6162b16db3..857dffc839 100644 --- a/web/source/keyboards/keyboard.ts +++ b/web/source/keyboards/keyboard.ts @@ -112,6 +112,19 @@ namespace com.keyman.keyboards { } } + /** + * @param {number} _PCommand event code (16,17,18) or 0 + * @param {Object} _PTarget target element + * @param {number} _PData 1 or 0 + * Notifies keyboard of keystroke or other event + */ + notify(_PCommand: number, _PTarget: text.OutputTarget, _PData: number) { // I2187 + // Good example use case - the Japanese CJK-picker keyboard + if(typeof(this.scriptObject['KNS']) == 'function') { + this.scriptObject['KNS'](_PCommand, _PTarget, _PData); + } + } + // TODO: Provide public property-retrieving methods on this class, rather than as part of // the KeyboardManager object. } diff --git a/web/source/kmwdomevents.ts b/web/source/kmwdomevents.ts index 1271fa3844..04c8ece88a 100644 --- a/web/source/kmwdomevents.ts +++ b/web/source/kmwdomevents.ts @@ -238,8 +238,9 @@ namespace com.keyman { this.keyman.uiManager.justActivated = false; var isActivating = this.keyman.uiManager.isActivating; - if(!isActivating) { - this.keyman.textProcessor.keyboardInterface.notifyKeyboard(0, text.Processor.getOutputTarget(Ltarg as HTMLElement), 0); // I2187 + let activeKeyboard = com.keyman.singleton.textProcessor.activeKeyboard; + if(!isActivating && activeKeyboard) { + activeKeyboard.notify(0, text.Processor.getOutputTarget(Ltarg as HTMLElement), 0); // I2187 } //e = this.keyman._GetEventObject(e); // I2404 - Manage IE events in IFRAMEs //TODO: is this really needed again???? @@ -343,11 +344,15 @@ namespace com.keyman { } DOMEventHandlers.states._DisableInput = false; + let activeKeyboard = com.keyman.singleton.textProcessor.activeKeyboard; if(!uiManager.justActivated) { if(target && text.Processor.getOutputTarget(target)) { text.Processor.getOutputTarget(target).deadkeys().clear(); } - this.keyman.textProcessor.keyboardInterface.notifyKeyboard(0, text.Processor.getOutputTarget(target), 1); // I2187 + + if(activeKeyboard) { + activeKeyboard.notify(0, text.Processor.getOutputTarget(target), 1); // I2187 + } } if(!uiManager.justActivated && DOMEventHandlers.states._SelectionControl != target) { diff --git a/web/source/text/kbdInterface.ts b/web/source/text/kbdInterface.ts index a0e2cbf34b..7e5f0fdd6a 100644 --- a/web/source/text/kbdInterface.ts +++ b/web/source/text/kbdInterface.ts @@ -229,22 +229,6 @@ namespace com.keyman.text { DOMEventHandlers.states._IgnoreNextSelChange = 1; } } - - - /** - * Function _NotifyKeyboard - * Scope Private - * @param {number} _PCommand event code (16,17,18) or 0 - * @param {Object} _PTarget target element - * @param {number} _PData 1 or 0 - * Description Notifies keyboard of keystroke or other event - */ - notifyKeyboard(_PCommand: number, _PTarget: OutputTarget, _PData: number) { // I2187 - // Good example use case - the Japanese CJK-picker keyboard - if(this.activeKeyboard != null && typeof(this.activeKeyboard.scriptObject['KNS']) == 'function') { - this.activeKeyboard.scriptObject['KNS'](_PCommand, _PTarget, _PData); - } - } /** * Function KT @@ -848,7 +832,6 @@ namespace com.keyman.text { */ output(dn: number, outputTarget: OutputTarget, s:string): void { this.resetContextCache(); - let keyman = com.keyman.singleton; outputTarget.saveProperties(); outputTarget.clearSelection(); @@ -860,11 +843,6 @@ namespace com.keyman.text { // Automatically manages affected deadkey positions. outputTarget.insertTextBeforeCaret(s); outputTarget.restoreProperties(); - - // Refresh element content after change (if needed) - if(typeof(keyman.refreshElementContent) == 'function') { - keyman.refreshElementContent(outputTarget.getElement()); - } } @@ -974,7 +952,6 @@ namespace com.keyman.text { * (i.e. for TSS_LAYER, if the layer is successfully selected) */ setStore(systemId: number, strValue: string, outputTarget: OutputTarget): boolean { - let keyman = com.keyman.singleton; this.resetContextCache(); if(systemId == KeyboardInterface.TSS_LAYER) { // Denote the changed store as part of the matched rule's behavior. diff --git a/web/source/text/processor.ts b/web/source/text/processor.ts index 4cfde433b6..face73c9da 100644 --- a/web/source/text/processor.ts +++ b/web/source/text/processor.ts @@ -495,6 +495,7 @@ namespace com.keyman.text { if(keyman.isEmbedded) { // A special embedded callback used to setup direct callbacks to app-native code. keyman['oninserttext'](ruleTransform.deleteLeft, ruleTransform.insert, ruleTransform.deleteRight); + keyman.refreshElementContent(outputTarget.getElement()); } // Since this method now performs changes for 'default' keystrokes, synthetic 'change' event generation @@ -675,7 +676,6 @@ namespace com.keyman.text { * @return {number} key code > 255 on success, or 0 if not found */ getVKDictionaryCode(keyName: string) { - let keyman = com.keyman.singleton; var activeKeyboard = this.activeKeyboard; if(!activeKeyboard.scriptObject['VKDictionary']) { var a=[]; @@ -985,6 +985,10 @@ namespace com.keyman.text { let keyman = com.keyman.singleton; let outputTarget = Levent.Ltarg; + if(!this.activeKeyboard) { + return false; + } + switch(Levent.Lcode) { case 8: outputTarget.deadkeys().clear(); @@ -996,7 +1000,7 @@ namespace com.keyman.text { case 144: case 145: // For eventual integration - we bypass an OSK update for physical keystrokes when in touch mode. - this.keyboardInterface.notifyKeyboard(Levent.Lcode, outputTarget, isKeyDown ? 1 : 0); + this.activeKeyboard.notify(Levent.Lcode, outputTarget, isKeyDown ? 1 : 0); if(!keyman.util.device.touchable) { return this._UpdateVKShift(Levent, Levent.Lcode-15, 1); // I2187 } else { @@ -1005,7 +1009,7 @@ namespace com.keyman.text { } if(Levent.LmodifierChange) { - this.keyboardInterface.notifyKeyboard(0, outputTarget, 1); + this.activeKeyboard.notify(0, outputTarget, 1); this._UpdateVKShift(Levent, 0, 1); }