loleaflet/src/layer/marker/TextInput.js | 15 ++++++++++++++- loleaflet/src/map/Map.js | 4 +--- 2 files changed, 15 insertions(+), 4 deletions(-)
New commits: commit f7663f37a2258b4088ba9c4e488d878f34705123 Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Thu Feb 13 10:10:28 2020 +0100 Commit: Jan Holesovsky <ke...@collabora.com> CommitDate: Thu Feb 13 10:28:45 2020 +0100 android: Control the keyboard appearing directly in TextInput.js. And add one more trick: If the keyboard is not supposed to be shown, set the read-only attribute for the textarea before the focus(), and remove it again after the blur(). Change-Id: I5ff4d0e093cb70737af205c04951d8dd58a35831 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88587 Tested-by: Jan Holesovsky <ke...@collabora.com> Reviewed-by: Jan Holesovsky <ke...@collabora.com> diff --git a/loleaflet/src/layer/marker/TextInput.js b/loleaflet/src/layer/marker/TextInput.js index 5f95d6a46..98138e761 100644 --- a/loleaflet/src/layer/marker/TextInput.js +++ b/loleaflet/src/layer/marker/TextInput.js @@ -151,14 +151,27 @@ L.TextInput = L.Layer.extend({ }, // Focus the textarea/contenteditable - focus: function() { + // @acceptInput (only on "mobile" (= mobile phone) or on iOS and Android in general) true if we want to + // accept key input, and show the virtual keyboard. + focus: function(acceptInput) { // Clicking or otherwise focusing the map should focus on the clipboard // container in order for the user to input text (and on-screen keyboards // to pop-up), unless the document is read only. if (this._map._permission !== 'edit') { return; } + + // Trick to avoid showing the software keyboard: Set the textarea + // read-only before focus() and reset it again after the blur() + if ((window.ThisIsAMobileApp || window.mode.isMobile()) && acceptInput !== true) + this._textArea.setAttribute('readonly', true); + this._textArea.focus(); + + if ((window.ThisIsAMobileApp || window.mode.isMobile()) && acceptInput !== true) { + this._textArea.blur(); + this._textArea.removeAttribute('readonly'); + } }, blur: function() { diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js index de9666179..ba848c2b2 100644 --- a/loleaflet/src/map/Map.js +++ b/loleaflet/src/map/Map.js @@ -908,9 +908,7 @@ L.Map = L.Evented.extend({ // @acceptInput (only on "mobile" (= mobile phone) or on iOS and Android in general) true if we want to // accept key input, and show the virtual keyboard. focus: function (acceptInput) { - this._textInput.focus(); - if ((window.ThisIsAMobileApp || window.mode.isMobile()) && acceptInput !== true) - this.blur(); + this._textInput.focus(acceptInput); }, // Lose focus to stop accepting keyboard input. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits