mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-14 20:59:25 +00:00
Merge pull request #4232 from keymanapp/fix/web/3697-osk-size-cookie-sync
fix(web): osk size & position after focus changes
This commit is contained in:
commit
2cd3f812ec
1 changed files with 23 additions and 16 deletions
|
|
@ -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();
|
||||
|
|
@ -797,6 +793,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 +905,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 +928,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 +1069,19 @@ namespace com.keyman.osk {
|
|||
* Description Get rectangle containing KMW Virtual Keyboard
|
||||
*/
|
||||
['getRect'](): OSKRect { // I2405
|
||||
let util = com.keyman.singleton.util;
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue