Merge pull request #4954 from keymanapp/fix/web/subkey-suggestions

fix(web): fixes subkey lookup for fat-finger processing
This commit is contained in:
Joshua Horton 2021-04-22 11:53:00 +07:00 committed by GitHub
commit bda0171448
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View file

@ -32,6 +32,8 @@ namespace com.keyman.keyboards {
proportionalX: number;
proportionalWidth: number;
sk?: ActiveKey[];
// Keeping things simple here, as this was added LATE in 14.0 beta.
// Could definitely extend in the future to instead return an object
// that denotes the 'nature' of the key.
@ -219,6 +221,18 @@ namespace com.keyman.keyboards {
return Lkc;
}
public getSubkey(id: string): ActiveKey {
if(this.sk) {
for(let key of this.sk) {
if(key.id == id) {
return key;
}
}
}
return null;
}
}
class ActiveRow implements LayoutRow {
@ -570,7 +584,13 @@ namespace com.keyman.keyboards {
keyId = keyId.replace(this.id + '-', '');
}
return this.keyMap[keyId];
let idComponents = keyId.split('::');
if(idComponents.length > 1) {
let baseKey = this.keyMap[idComponents[0]];
return baseKey.getSubkey(idComponents[1]);
} else {
return this.keyMap[keyId];
}
}
}

View file

@ -1090,6 +1090,9 @@ namespace com.keyman.osk {
if(popupKeyID == baseKeyID) {
baseKeyMass += popupKeyMass;
popupKeyMass = 0;
} else {
// We namespace it so that lookup operations know to find it via its base key.
popupKeyID = `${baseKeyID}::${popupKeyID}`;
}
// Compute the normalization factor