mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-09 02:15:32 +00:00
refactor(web): simplifies embedded executePopupKey
This commit is contained in:
parent
56ac223e08
commit
2d06c65412
2 changed files with 14 additions and 42 deletions
|
|
@ -360,8 +360,8 @@ namespace com.keyman.text {
|
|||
|
||||
keymanweb.domManager.initActiveElement(Lelem);
|
||||
|
||||
var nextLayer: string;
|
||||
var delegator: com.keyman.osk.embedded.SubkeyDelegator = null;
|
||||
let selectedKey: com.keyman.osk.OSKKeySpec = null;
|
||||
// This should be set if we're within this method... but it's best to guard against nulls here, just in case.
|
||||
if(osk.vkbd.subkeyDelegator) {
|
||||
delegator = osk.vkbd.subkeyDelegator as com.keyman.osk.embedded.SubkeyDelegator;
|
||||
|
|
@ -371,15 +371,14 @@ namespace com.keyman.text {
|
|||
var found = false;
|
||||
|
||||
if(baseKey.coreID == keyName) {
|
||||
nextLayer = baseKey.nextlayer;
|
||||
selectedKey = baseKey;
|
||||
found = true;
|
||||
} else {
|
||||
// Search for the specified subkey so we can retrieve its useful properties.
|
||||
// It should be within the popupBaseKey's subkey list.
|
||||
for(let subKey of baseKey.sk) {
|
||||
if(subKey.coreID == keyName) {
|
||||
// ... to consider: why are we not just taking the keyspec wholesale right here?
|
||||
nextLayer = subKey.nextlayer;
|
||||
selectedKey = subKey;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -395,42 +394,12 @@ namespace com.keyman.text {
|
|||
console.warn("No base key exists for the subkey being executed: '" + origArg + "'");
|
||||
}
|
||||
|
||||
let Codes = com.keyman.text.Codes;
|
||||
|
||||
// Check the virtual key
|
||||
let Lkc: com.keyman.text.KeyEvent = {
|
||||
Lmodifiers: keyShiftState,
|
||||
Lstates: 0,
|
||||
Lcode: Codes.keyCodes[keyName],
|
||||
LisVirtualKey: true,
|
||||
kName: keyName,
|
||||
kNextLayer: nextLayer,
|
||||
vkCode: null, // was originally undefined
|
||||
isSynthetic: true,
|
||||
device: keymanweb.util.device.coreSpec
|
||||
};
|
||||
|
||||
// Process modifier key action
|
||||
if(core.keyboardProcessor.selectLayer(Lkc, true)) { // ignores key's 'nextLayer' property for this check
|
||||
return true;
|
||||
let Lkc: com.keyman.text.KeyEvent = null;
|
||||
if(selectedKey) {
|
||||
Lkc = osk.vkbd.keyEventFromSpec(selectedKey as com.keyman.keyboards.ActiveKey, null);
|
||||
Lkc.vkCode=Lkc.Lcode;
|
||||
}
|
||||
|
||||
// While we can't source the base KeyEvent properties for embedded subkeys the same way as native,
|
||||
// we can handle many other pre-processing steps the same way with this common method.
|
||||
core.keyboardProcessor.setSyntheticEventDefaults(Lkc);
|
||||
|
||||
//if(!Lkc.Lcode) return false; // Value is now zero if not known (Build 347)
|
||||
//Build 353: revert to prior test to try to fix lack of KMEI output, May 1, 2014
|
||||
if(isNaN(Lkc.Lcode) || !Lkc.Lcode) {
|
||||
// Addresses modifier SHIFT keys.
|
||||
if(nextLayer) {
|
||||
core.keyboardProcessor.selectLayer(Lkc);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Lkc.vkCode=Lkc.Lcode;
|
||||
|
||||
if(delegator) {
|
||||
delegator.resolve(Lkc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -960,8 +960,6 @@ namespace com.keyman.osk {
|
|||
// Turn off key highlighting (or preview)
|
||||
this.highlightKey(e,false);
|
||||
|
||||
let core = com.keyman.singleton.core; // only singleton-based ref currently needed here.
|
||||
|
||||
// Future note: we need to refactor osk.OSKKeySpec to instead be a 'tag field' for
|
||||
// keyboards.ActiveKey. (Prob with generics, allowing the Web-only parts to
|
||||
// be fully specified within the tag.)
|
||||
|
|
@ -973,7 +971,13 @@ namespace com.keyman.osk {
|
|||
console.error("OSK key with ID '" + e.id + "', keyID '" + e.keyId + "' missing needed specification");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return the event object.
|
||||
return this.keyEventFromSpec(keySpec, touch);
|
||||
}
|
||||
|
||||
keyEventFromSpec(keySpec: keyboards.ActiveKey, touch?: Touch) {
|
||||
let core = com.keyman.singleton.core; // only singleton-based ref currently needed here.
|
||||
|
||||
// Start: mirrors _GetKeyEventProperties
|
||||
|
||||
|
|
@ -994,8 +998,7 @@ namespace com.keyman.osk {
|
|||
Lkc.source = touch;
|
||||
Lkc.keyDistribution = this.getTouchProbabilities(touch);;
|
||||
}
|
||||
|
||||
// Return the event object.
|
||||
|
||||
return Lkc;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue