fix(android/engine): Fix backspace on Android 5.0

This commit is contained in:
Darcy Wong 2021-09-06 08:03:47 +07:00
parent f639ad55a3
commit 31b0cf1fb4

View file

@ -39,6 +39,7 @@
kmw['setActiveElement'](ta);
ta.readOnly = false;
checkTextArea();
// Tell KMW the default banner height to use
com.keyman.osk.Banner.DEFAULT_HEIGHT =
@ -327,6 +328,27 @@
return hexString;
}
/**
* Check the WebView version and determine if the textarea that KeymanWeb uses needs to be "visible".
* Normally, this textarea is not displayed to avoid redundant layout calculations.
* In older WebViews on Android 5.0 though, selectionStart and selectionEnd positions fail to
* update unless the textarea is visible.
* Reference: Issue #5376
*/
function checkTextArea() {
var uaRe = /Chrome\/([0-9]*)./g;
var chromeMajorVersion = uaRe.exec(navigator.userAgent);
if (chromeMajorVersion && parseInt(chromeMajorVersion[1]) <= 37) {
var ta = document.getElementById('ta');
if (ta != null) {
ta.style.display = '';
ta.style.position = 'absolute';
ta.style.left = '-500px';
ta.style.top = '0px';
}
}
}
</script>
<style type="text/css">
body {background-color:#000000;}