From c7310e0b8600c11e848e65deeb66edd8683b3b10 Mon Sep 17 00:00:00 2001 From: jahorton Date: Thu, 22 Apr 2021 11:00:07 +0700 Subject: [PATCH] fix(web): fixes subkey lookup for fat-finger processing --- .../src/keyboards/activeLayout.ts | 22 ++++++++++++++++++- web/source/osk/visualKeyboard.ts | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/common/core/web/keyboard-processor/src/keyboards/activeLayout.ts b/common/core/web/keyboard-processor/src/keyboards/activeLayout.ts index 84e06f82c1..ae8d65cafb 100644 --- a/common/core/web/keyboard-processor/src/keyboards/activeLayout.ts +++ b/common/core/web/keyboard-processor/src/keyboards/activeLayout.ts @@ -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]; + } } } diff --git a/web/source/osk/visualKeyboard.ts b/web/source/osk/visualKeyboard.ts index b86ffe745c..3870e441d2 100644 --- a/web/source/osk/visualKeyboard.ts +++ b/web/source/osk/visualKeyboard.ts @@ -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