[Libreoffice-commits] online.git: loleaflet/src
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue May 21 13:11:12 UTC 2019
loleaflet/src/control/Control.MobileInput.js | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
New commits:
commit 936f3a143520c5a8c72fd0976c88580d3393d034
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue May 21 15:57:36 2019 +0300
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Tue May 21 16:05:57 2019 +0300
tdf#125410: Handle pasting of text/plain strings into the iOS app
Also, initialise this._keyHandled as true in L.Control.MobileInput, as
that is the value it has between key event sequences, so presumably it
should be so before the first key is hit, too.
Change-Id: Ie67e9fcdd14871e76f9d9487c14f03ae54476e60
diff --git a/loleaflet/src/control/Control.MobileInput.js b/loleaflet/src/control/Control.MobileInput.js
index 5a05025a9..392d9b30d 100644
--- a/loleaflet/src/control/Control.MobileInput.js
+++ b/loleaflet/src/control/Control.MobileInput.js
@@ -21,6 +21,11 @@ L.Control.MobileInput = L.Control.extend({
this._currentKeysDown = {};
this._ignoreKeypress = false;
this._isMobileSafariOriOSApp = window.ThisIsTheiOSApp || navigator.platform === 'iPad' || navigator.platform === 'iPhone';
+
+ // The value of _keyHandled after a complete input sequence of a plain character,
+ // before the next character input, is true, so surely it should then be true from
+ // the start, before the first character input?
+ this._keyHandled = true;
},
onAdd: function () {
@@ -105,6 +110,7 @@ L.Control.MobileInput = L.Control.extend({
L.DomEvent.on(this._textArea, stopEvents, L.DomEvent.stopPropagation)
.on(this._textArea, 'keydown keypress keyup', this.onKeyEvents, this)
.on(this._textArea, 'textInput', this.onTextInput, this)
+ .on(this._textArea, 'paste', this.onPaste, this)
.on(this._textArea, 'focus', this.onGotFocus, this)
.on(this._textArea, 'blur', this.onLostFocus, this);
if (!this._isMobileSafariOriOSApp)
@@ -241,7 +247,7 @@ L.Control.MobileInput = L.Control.extend({
},
onTextInput: function (e) {
- // console.log('==> onTextInput: _keyHandled=' + this._keyHandled);
+ // console.log('==> onTextInput: "' + e.data + '" _keyHandled=' + this._keyHandled);
if (!this._keyHandled) {
this._textData = e.data;
this._textArea.value = '';
@@ -250,6 +256,23 @@ L.Control.MobileInput = L.Control.extend({
L.DomEvent.stopPropagation(e);
},
+ onPaste: function (e) {
+ var i;
+ for (i = 0; i < e.clipboardData.items.length; ++i) {
+ if (e.clipboardData.items[i].kind === 'string' && e.clipboardData.items[i].type === 'text/plain') {
+ var map = this._map;
+ e.clipboardData.items[i].getAsString(function (s) {
+ var k;
+ for (k = 0; k < s.length; ++k) {
+ map._docLayer._postKeyboardEvent('input', s[k].charCodeAt(), 0);
+ map._docLayer._postKeyboardEvent('up', s[k].charCodeAt(), 0);
+ }
+ });
+ break;
+ }
+ }
+ },
+
onInput: function (e) {
// console.log('==> onInput: inputType=' + e.inputType);
var backSpace = this._map.keyboard._toUNOKeyCode(8);
More information about the Libreoffice-commits
mailing list