From 2e30d8232b610ffbf941a4e387c70cf019e72eae Mon Sep 17 00:00:00 2001 From: Joshua Horton Date: Wed, 14 Jun 2017 10:34:39 +0700 Subject: [PATCH] Fixes issues with UI focus handling that interfered with control-by-control handling of languages. Also fixes issues with the Toggle UI displaying for API-disabled controls. --- web/source/keymanweb.js | 12 +++++++++--- web/source/kmwuitoggle.js | 15 +++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/web/source/keymanweb.js b/web/source/keymanweb.js index a07d10a682..870b0c376f 100644 --- a/web/source/keymanweb.js +++ b/web/source/keymanweb.js @@ -2105,7 +2105,7 @@ * @return {boolean} always true (?) */ keymanweb._ControlFocus = function(e) - { + { var Ltarg, Ln; if(!keymanweb._Enabled) return true; e = keymanweb._GetEventObject(e); // I2404 - Manage IE events in IFRAMEs @@ -2161,7 +2161,7 @@ else keymanweb._ActiveControl.LDefaultInternalName = keymanweb._ActiveKeyboard == null ? '' : keymanweb._ActiveKeyboard['KI']; } - + //TODO: the logic of the following line doesn't look right!! Both variables are true, but that doesn't make sense! //_Debug(keymanweb._IsIEEditableIframe(Ltarg,1) + '...' +keymanweb._IsMozillaEditableIframe(Ltarg,1)); if(!keymanweb._IsIEEditableIframe(Ltarg,1) || !keymanweb._IsMozillaEditableIframe(Ltarg,1)) @@ -2289,13 +2289,19 @@ ////keymanweb._SelectionControl = null; keymanweb._LastActiveElement = Ltarg; - + if(keymanweb._ActiveControl != null && keymanweb._ActiveControl.LDefaultInternalName != null) if(keymanweb._ActiveKeyboard == null) keymanweb._ActiveControl.LDefaultInternalName = ''; else keymanweb._ActiveControl.LDefaultInternalName = keymanweb._ActiveKeyboard['KI']; + /* If the KeymanWeb UI is active as a user changes controls, all UI-based effects should be restrained to this control in case + * the user is manually specifying languages on a per-control basis. + */ + + keymanweb._JustActivatedKeymanWebUI = 0; + keymanweb._ActiveControl = null; if(!keymanweb._IsActivatingKeymanWebUI) keymanweb._NotifyKeyboard(0,Ltarg,0); // I2187 diff --git a/web/source/kmwuitoggle.js b/web/source/kmwuitoggle.js index 7474dd5358..d4fe3e221d 100644 --- a/web/source/kmwuitoggle.js +++ b/web/source/kmwuitoggle.js @@ -52,9 +52,20 @@ try { ui.doFocus = function(someElement,focusing) { // This callback must be ignored until UI is initialized, or for touch devices (which can never initialize the UI) - if(!ui.initialized) return; + if(!ui.initialized) { + return; + } - if(window.event) someElement=window.event.srcElement; + if(window.event) { + someElement=window.event.srcElement; + } + + // Hides the Toggle interface if a control has KeymanWeb disabled by API calls. + if(keymanweb._ActiveControl != null){ + if(!keymanweb._ActiveControl.LEnabled) { + focusing = false; + } + } if(focusing) {