refactor(web/engine): notify() -> keyboard, embedded refresh -> Processor

This commit is contained in:
jahorton 2020-03-21 22:07:23 +07:00
parent b3b6bea5d7
commit c0fab31fc9
4 changed files with 28 additions and 29 deletions

View file

@ -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.
}

View file

@ -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<FocusEvent>(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) {

View file

@ -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.

View file

@ -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);
}