Merge pull request #6849 from keymanapp/fix/web/6799-caps-state-only-from-caps-layer-for-touch

fix(web): Maintain separate Caps Lock states for touch and physical
This commit is contained in:
Marc Durdin 2022-07-06 05:41:18 +10:00 committed by GitHub
commit 1ee5aaa63e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 20 deletions

View file

@ -190,10 +190,14 @@ namespace com.keyman.text {
}
setSyntheticEventDefaults(Lkc: text.KeyEvent) {
// Set the flags for the state keys.
Lkc.Lstates |= this.stateKeys['K_CAPS'] ? Codes.modifierCodes['CAPS'] : Codes.modifierCodes['NO_CAPS'];
Lkc.Lstates |= this.stateKeys['K_NUMLOCK'] ? Codes.modifierCodes['NUM_LOCK'] : Codes.modifierCodes['NO_NUM_LOCK'];
Lkc.Lstates |= this.stateKeys['K_SCROLL'] ? Codes.modifierCodes['SCROLL_LOCK'] : Codes.modifierCodes['NO_SCROLL_LOCK'];
// Set the flags for the state keys - for desktop devices. For touch
// devices, the only state key in use currently is Caps Lock, which is set
// when the 'caps' layer is active in ActiveKey::constructBaseKeyEvent.
if(!Lkc.device.touchable) {
Lkc.Lstates |= this.stateKeys['K_CAPS'] ? Codes.modifierCodes['CAPS'] : Codes.modifierCodes['NO_CAPS'];
Lkc.Lstates |= this.stateKeys['K_NUMLOCK'] ? Codes.modifierCodes['NUM_LOCK'] : Codes.modifierCodes['NO_NUM_LOCK'];
Lkc.Lstates |= this.stateKeys['K_SCROLL'] ? Codes.modifierCodes['SCROLL_LOCK'] : Codes.modifierCodes['NO_SCROLL_LOCK'];
}
// Set LisVirtualKey to false to ensure that nomatch rule does fire for U_xxxx keys
if(Lkc.kName && Lkc.kName.substr(0,2) == 'U_') {
@ -272,7 +276,7 @@ namespace com.keyman.text {
matchBehavior.mergeInDefaults(defaultBehavior);
}
matchBehavior.triggerKeyDefault = false; // We've triggered it successfully.
} // If null, we must rely on something else (like the browser, in DOM-aware code) to fulfill the default.
} // If null, we must rely on something else (like the browser, in DOM-aware code) to fulfill the default.
this.keyboardInterface.activeTargetOutput = null;
}
@ -688,21 +692,10 @@ namespace com.keyman.text {
this.layerId = 'default';
}
this.updateStateKeysFromLayer();
let baseModifierState = text.KeyboardProcessor.getModifierState(this.layerId);
this.modStateFlags = baseModifierState | keyEvent.Lstates;
}
public updateStateKeysFromLayer() {
if(this.device.formFactor != utils.FormFactor.Desktop) {
// The caps layer works slightly differently on touch than on desktop.
// It's a single layer with no ability to mix with other modifiers
// We need to make sure that the state is kept in sync with the layer.
this.stateKeys['K_CAPS'] = this.layerId == 'caps';
}
}
static isModifier(Levent: KeyEvent): boolean {
switch(Levent.Lcode) {
case 16: //"K_SHIFT":16,"K_CONTROL":17,"K_ALT":18
@ -748,7 +741,6 @@ namespace com.keyman.text {
resetContext() {
this.layerId = 'default';
this.updateStateKeysFromLayer();
this.keyboardInterface.resetContextCache();
this._UpdateVKShift(null);
};
@ -758,7 +750,6 @@ namespace com.keyman.text {
let layout = this.activeKeyboard.layout(device.formFactor);
if(layout.getLayer('numeric')) {
this.layerId = 'numeric';
this.updateStateKeysFromLayer();
}
}
};

View file

@ -399,7 +399,7 @@ namespace com.keyman.osk {
* @param outputTarget
* @returns true
*/
suggestionApplied(outputTarget: text.OutputTarget): boolean {
suggestionApplied: (outputTarget: text.OutputTarget) => boolean = function(this: SuggestionBanner, outputTarget: text.OutputTarget) {
const keyman = com.keyman.singleton;
// Tell the keyboard that the current layer has not changed
keyman.core.keyboardProcessor.newLayerStore.set('');
@ -411,7 +411,7 @@ namespace com.keyman.osk {
?.finalize(keyman.core.keyboardProcessor, outputTarget, true);
return true;
};
}.bind(this);
postConfigure() {
let keyman = com.keyman.singleton;
@ -427,6 +427,7 @@ namespace com.keyman.osk {
keyman.core.languageProcessor.removeListener('suggestionsready', manager.updateSuggestions);
keyman.core.languageProcessor.removeListener('tryaccept', manager.tryAccept);
keyman.core.languageProcessor.removeListener('tryrevert', manager.tryRevert);
keyman.core.languageProcessor.removeListener('suggestionapplied', this.suggestionApplied);
}
}