From 360c2cd71c84112e2691dcce56e0ca9ade25b54f Mon Sep 17 00:00:00 2001 From: jahorton Date: Tue, 12 Jan 2021 12:02:30 +0700 Subject: [PATCH 1/3] fix(web): osk size & position after focus changes --- web/source/osk/oskManager.ts | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/web/source/osk/oskManager.ts b/web/source/osk/oskManager.ts index b519a75246..c36ac26e39 100644 --- a/web/source/osk/oskManager.ts +++ b/web/source/osk/oskManager.ts @@ -797,6 +797,8 @@ namespace com.keyman.osk { var r=this.getRect(); this.width=r.width; this.height=r.height; + this.x = r.left; + this.y = r.top; e.cancelBubble = true; return false; } @@ -907,11 +909,7 @@ namespace com.keyman.osk { newHeight=0.5*screen.height; } - if(this.vkbd) { - this.vkbd.kbdDiv.style.width=newWidth+'px'; - this.vkbd.kbdDiv.style.height=newHeight+'px'; - this.vkbd.kbdDiv.style.fontSize=(newHeight/8)+'px'; - } + this.setSize(newWidth, newHeight); // and OSK position if user located if(this.x == -1 || this.y == -1 || (!this._Box)) { @@ -934,6 +932,19 @@ namespace com.keyman.osk { return true; } + private setSize(width?: number, height?: number) { + if(width && height) { + this.width = width; + this.height = height; + } + + if(this.vkbd) { + this.vkbd.kbdDiv.style.width=this.width+'px'; + this.vkbd.kbdDiv.style.height=this.height+'px'; + this.vkbd.kbdDiv.style.fontSize=(this.height/8)+'px'; + } + } + getWidthFromCookie(): number { let util = com.keyman.singleton.util; @@ -1062,19 +1073,17 @@ namespace com.keyman.osk { * Description Get rectangle containing KMW Virtual Keyboard */ ['getRect'](): OSKRect { // I2405 - let util = com.keyman.singleton.util; var p: OSKRect = {}; + p['left'] = p.left = dom.Utils.getAbsoluteX(this._Box); + p['top'] = p.top = dom.Utils.getAbsoluteY(this._Box); + if(this.vkbd) { - p['left'] = p.left = dom.Utils.getAbsoluteX(this.vkbd.kbdDiv); - p['top'] = p.top = dom.Utils.getAbsoluteY(this.vkbd.kbdDiv); p['width'] = p.width = dom.Utils.getAbsoluteX(this.vkbd.kbdHelpDiv) - dom.Utils.getAbsoluteX(this.vkbd.kbdDiv) + this.vkbd.kbdHelpDiv.offsetWidth; p['height'] = p.height = dom.Utils.getAbsoluteY(this.vkbd.kbdHelpDiv) - dom.Utils.getAbsoluteY(this.vkbd.kbdDiv) + this.vkbd.kbdHelpDiv.offsetHeight; } else { - p['left'] = p.left = dom.Utils.getAbsoluteX(this._Box); - p['top'] = p.top = dom.Utils.getAbsoluteY(this._Box); p['width'] = p.width = dom.Utils.getAbsoluteX(this._Box) + this._Box.offsetWidth; p['height'] = p.height = dom.Utils.getAbsoluteY(this._Box) + this._Box.offsetHeight; } @@ -1280,7 +1289,9 @@ namespace com.keyman.osk { if(device.formFactor == 'desktop') { Ls.position='absolute'; Ls.display='block'; //Ls.visibility='visible'; Ls.left='0px'; - this.loadCookie(); + + this.setSize(); + if(Px >= 0) { //probably never happens, legacy support only Ls.left = Px + 'px'; Ls.top = Py + 'px'; } else { From f20098244aebc2a8b157c2e2e147d7bfd9e69262 Mon Sep 17 00:00:00 2001 From: jahorton Date: Tue, 12 Jan 2021 12:48:19 +0700 Subject: [PATCH 2/3] fix(web): fixes cookie/state mismatch --- web/source/osk/oskManager.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/web/source/osk/oskManager.ts b/web/source/osk/oskManager.ts index c36ac26e39..b3c3cfa726 100644 --- a/web/source/osk/oskManager.ts +++ b/web/source/osk/oskManager.ts @@ -686,12 +686,8 @@ namespace com.keyman.osk { newWidth=0.5*screen.height; } - // Set OSK width - this.vkbd.kbdDiv.style.width=newWidth+'px'; - - // Explicitly change OSK height and font size - cannot safely rely on scaling from font - this.vkbd.kbdDiv.style.height=newHeight+'px'; - this.vkbd.kbdDiv.style.fontSize=(newHeight/8)+'px'; + // Explicitly set OSK width, height, and font size - cannot safely rely on scaling from font + this.setSize(newWidth, newHeight); if(e && e.preventDefault) { e.preventDefault(); @@ -1290,7 +1286,7 @@ namespace com.keyman.osk { Ls.position='absolute'; Ls.display='block'; //Ls.visibility='visible'; Ls.left='0px'; - this.setSize(); + this.loadCookie(); if(Px >= 0) { //probably never happens, legacy support only Ls.left = Px + 'px'; Ls.top = Py + 'px'; From b9437c08e456e626ae8d6fa11b08c7678aef1b4e Mon Sep 17 00:00:00 2001 From: jahorton Date: Tue, 12 Jan 2021 12:53:47 +0700 Subject: [PATCH 3/3] chore(web): mild cleanup --- web/source/osk/oskManager.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/source/osk/oskManager.ts b/web/source/osk/oskManager.ts index b3c3cfa726..23b714f632 100644 --- a/web/source/osk/oskManager.ts +++ b/web/source/osk/oskManager.ts @@ -1071,6 +1071,8 @@ namespace com.keyman.osk { ['getRect'](): OSKRect { // I2405 var p: OSKRect = {}; + // Always return these based upon _Box; using this.vkbd will fail to account for banner and/or + // the desktop OSK border. p['left'] = p.left = dom.Utils.getAbsoluteX(this._Box); p['top'] = p.top = dom.Utils.getAbsoluteY(this._Box); @@ -1285,9 +1287,7 @@ namespace com.keyman.osk { if(device.formFactor == 'desktop') { Ls.position='absolute'; Ls.display='block'; //Ls.visibility='visible'; Ls.left='0px'; - this.loadCookie(); - if(Px >= 0) { //probably never happens, legacy support only Ls.left = Px + 'px'; Ls.top = Py + 'px'; } else {