mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-10 01:27:43 +00:00
Merge pull request #4077 from keymanapp/fix/web/engine/keyfind-misfire
fix(web/engine): findNearestKey erroneously returned key child
This commit is contained in:
commit
68f35b0200
1 changed files with 7 additions and 7 deletions
|
|
@ -1313,19 +1313,19 @@ namespace com.keyman.osk {
|
|||
// Find minimum distance from any key
|
||||
var k, k0=0, dx, dxMax=24, dxMin=100000, x1, x2;
|
||||
for(k = 0; k < t.childNodes.length; k++) {
|
||||
let childNode = t.childNodes[k] as HTMLElement; // gets the .kmw-key-square containing a key
|
||||
if(childNode.firstChild) {
|
||||
childNode = childNode.firstChild as HTMLElement; // gets the actual key element.
|
||||
}
|
||||
let keySquare = t.childNodes[k] as HTMLElement; // gets the .kmw-key-square containing a key
|
||||
// Find the actual key element.
|
||||
let childNode = keySquare.firstChild ? keySquare.firstChild as HTMLElement: keySquare;
|
||||
|
||||
if(childNode.className !== undefined && (childNode.className.indexOf('key-hidden') >= 0)
|
||||
|| (childNode.className.indexOf('key-blank') >= 0)){
|
||||
continue;
|
||||
}
|
||||
x1 = childNode.offsetLeft;
|
||||
x2 = x1 + childNode.offsetWidth;
|
||||
x1 = keySquare.offsetLeft;
|
||||
x2 = x1 + keySquare.offsetWidth;
|
||||
if(x >= x1 && x <= x2) {
|
||||
// Within the key square
|
||||
return <KeyElement> childNode.firstChild;
|
||||
return <KeyElement> childNode;
|
||||
}
|
||||
dx = x1 - x;
|
||||
if(dx >= 0 && dx < dxMin) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue