mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-26 17:47:40 +00:00
Merge pull request #2151 from keymanapp/web-set-active-element
[Web] Fixes setLastActiveElement for touch form factors
This commit is contained in:
commit
250d07e030
3 changed files with 24 additions and 10 deletions
|
|
@ -3,6 +3,9 @@
|
|||
## 13.0 alpha
|
||||
* Start version 13.0
|
||||
|
||||
## 2019-10-01 12.0.87 beta
|
||||
* Fixes the `setLastActiveElement` API function for touch form factors (#2151)
|
||||
|
||||
## 2019-09-23 12.0.86 beta
|
||||
* Fixes issue in Toolbar UI for some keyboards with language ids that include subtags (#2116)
|
||||
* Fixes issue with '=' key use on certain platforms in Firefox (#2118)
|
||||
|
|
|
|||
|
|
@ -1182,7 +1182,14 @@ namespace com.keyman {
|
|||
// Allow external focusing KMEW-123
|
||||
if(arguments.length > 1 && setFocus) {
|
||||
if(this.keyman.util.device.touchable) {
|
||||
this.keyman.touchAliasing.setFocus();
|
||||
var tEvent = {
|
||||
clientX: 0,
|
||||
clientY: 0,
|
||||
target: e as HTMLElement
|
||||
};
|
||||
|
||||
// Kinda hacky, but gets the job done.
|
||||
(this.keyman.touchAliasing as DOMTouchHandlers).setFocusWithTouch(tEvent);
|
||||
} else {
|
||||
this.focusLastActiveElement();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -488,8 +488,6 @@ namespace com.keyman {
|
|||
*
|
||||
*/
|
||||
setFocus: (e?: TouchEvent|MSPointerEvent) => void = function(this: DOMTouchHandlers, e?: TouchEvent|MSPointerEvent): void {
|
||||
var osk = this.keyman.osk;
|
||||
|
||||
DOMEventHandlers.states.setFocusTimer();
|
||||
|
||||
var tEvent: {
|
||||
|
|
@ -498,8 +496,8 @@ namespace com.keyman {
|
|||
target?: EventTarget;
|
||||
};
|
||||
|
||||
if(dom.Utils.instanceof(e, "TouchEvent")) {
|
||||
tEvent=(e as TouchEvent).touches[0];
|
||||
if(e && dom.Utils.instanceof(e, "TouchEvent")) {
|
||||
tEvent=(e as TouchEvent).touches[0];
|
||||
} else { // Allow external code to set focus and thus display the OSK on touch devices if required (KMEW-123)
|
||||
tEvent={clientX:0, clientY:0}
|
||||
// Will usually be called from setActiveElement, which should define DOMEventHandlers.states.lastActiveElement
|
||||
|
|
@ -509,16 +507,22 @@ namespace com.keyman {
|
|||
} else {
|
||||
tEvent.target = this.keyman.domManager.sortedInputs[0]['kmw_ip'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.setFocusWithTouch(tEvent);
|
||||
}.bind(this);
|
||||
|
||||
setFocusWithTouch(tEvent: {clientX: number, clientY: number, target?: EventTarget}) {
|
||||
var osk = this.keyman.osk;
|
||||
|
||||
var touchX=tEvent.clientX,touchY=tEvent.clientY;
|
||||
var tTarg=tEvent.target as HTMLElement;
|
||||
var scroller: HTMLElement;
|
||||
|
||||
// Identify the scroller element
|
||||
if(dom.Utils.instanceof(tTarg, "HTMLSpanElement")) {
|
||||
if(tTarg && dom.Utils.instanceof(tTarg, "HTMLSpanElement")) {
|
||||
scroller=tTarg.parentNode as HTMLElement;
|
||||
} else if(tTarg.className != null && tTarg.className.indexOf('keymanweb-input') >= 0) {
|
||||
} else if(tTarg && (tTarg.className != null && tTarg.className.indexOf('keymanweb-input') >= 0)) {
|
||||
scroller=tTarg.firstChild as HTMLElement;
|
||||
} else {
|
||||
scroller=tTarg;
|
||||
|
|
@ -553,7 +557,7 @@ namespace com.keyman {
|
|||
}
|
||||
|
||||
// If clicked on DIV, set caret to end of text
|
||||
if(dom.Utils.instanceof(tTarg, "TouchAliasElement")) {
|
||||
if(tTarg && dom.Utils.instanceof(tTarg, "TouchAliasElement")) {
|
||||
var x,cp;
|
||||
x=dom.Utils.getAbsoluteX(scroller.firstChild as HTMLElement);
|
||||
if(target.dir == 'rtl') {
|
||||
|
|
@ -655,7 +659,7 @@ namespace com.keyman {
|
|||
if(this._CommonFocusHelper(target)) {
|
||||
return;
|
||||
}
|
||||
}.bind(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close OSK and remove simulated caret on losing focus
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue