loleaflet/src/control/Control.MobileInput.js | 43 ++++++++++++--------------- 1 file changed, 20 insertions(+), 23 deletions(-)
New commits: commit 6baa59678c34ec1e618ba0a2ac2b74983fbbd858 Author: Jan Holesovsky <[email protected]> AuthorDate: Thu Oct 4 00:53:06 2018 +0200 Commit: Aron Budea <[email protected]> CommitDate: Thu Oct 4 01:06:25 2018 +0200 Cleanup the debugging logging. Change-Id: I52ba4be4017a1b4d7a2464c078ec2144511f11f7 Reviewed-on: https://gerrit.libreoffice.org/61338 Reviewed-by: Aron Budea <[email protected]> Tested-by: Aron Budea <[email protected]> diff --git a/loleaflet/src/control/Control.MobileInput.js b/loleaflet/src/control/Control.MobileInput.js index 9439f0221..0530cab21 100644 --- a/loleaflet/src/control/Control.MobileInput.js +++ b/loleaflet/src/control/Control.MobileInput.js @@ -89,9 +89,6 @@ L.Control.MobileInput = L.Control.extend({ docLayer = this._map._docLayer, unoKeyCode = handler._toUNOKeyCode(keyCode); - console.log('onKeyEvent: e.type === ' + e.type); - console.log('onKeyEvent: e.keyCode === "' + e.keyCode + '"'); - console.log('onKeyEvent: e.charCode === "' + e.charCode + '"'); this._keyHandled = this._keyHandled || false; if (this._isComposing) { if (keyCode === 229 && charCode === 0) { @@ -138,8 +135,7 @@ L.Control.MobileInput = L.Control.extend({ onCompEvents: function (e) { var map = this._map; - console.log('onCompEvents: e.type === ' + e.type); - console.log('onCompEvents: e.data === "' + e.data + '"'); + if (e.type === 'compositionstart' || e.type === 'compositionupdate') { this._isComposing = true; // we are starting composing with IME this._composingData = e.data; // cache what we have composed so far @@ -154,9 +150,6 @@ L.Control.MobileInput = L.Control.extend({ }, onTextInput: function (e) { - console.log('onTextInput: e.type === ' + e.type); - console.log('onTextInput: e.data === "' + e.data + '"'); - if (!this._keyHandled) { this._textData = e.data; this._textArea.value = ''; @@ -166,9 +159,8 @@ L.Control.MobileInput = L.Control.extend({ }, onInput: function (e) { - console.log('onInput: e.inputType === ' + e.inputType); - var backSpace = this._map.keyboard._toUNOKeyCode(8); + // deferred processing of composition text or normal text; we can get // both in some cases, and based on the input event we need to decide // which one we actually need to use commit 10bfc4b449577590c4de82cb15d73204be053a3c Author: Jan Holesovsky <[email protected]> AuthorDate: Thu Oct 4 00:41:34 2018 +0200 Commit: Aron Budea <[email protected]> CommitDate: Thu Oct 4 01:06:16 2018 +0200 android chrome: Make the insertion of . , ! $ and similar chars work. The trick is that actually the 'onInput' (the 'input') event decides what data we should actually use - if those from compose event, or from the text input event. With this, things finally seem to work reasonably well - I am able to insert even emoji :-) Change-Id: I9f19d1e56e4e638cf88b8497abb8eefd24e82cee Reviewed-on: https://gerrit.libreoffice.org/61337 Reviewed-by: Aron Budea <[email protected]> Tested-by: Aron Budea <[email protected]> diff --git a/loleaflet/src/control/Control.MobileInput.js b/loleaflet/src/control/Control.MobileInput.js index 45920f63a..9439f0221 100644 --- a/loleaflet/src/control/Control.MobileInput.js +++ b/loleaflet/src/control/Control.MobileInput.js @@ -143,9 +143,6 @@ L.Control.MobileInput = L.Control.extend({ if (e.type === 'compositionstart' || e.type === 'compositionupdate') { this._isComposing = true; // we are starting composing with IME this._composingData = e.data; // cache what we have composed so far - if (e.data) { - map._docLayer._postCompositionEvent(0, 'input', e.data); - } } if (e.type === 'compositionend') { @@ -161,17 +158,7 @@ L.Control.MobileInput = L.Control.extend({ console.log('onTextInput: e.data === "' + e.data + '"'); if (!this._keyHandled) { - // Hack for making space in combination with autocompletion text - // input work in Chrome on Andorid. - // - // Chrome (Android) IME triggers keyup/keydown input with - // code 229 when hitting space (as with all composiiton events) - // with addition to 'textinput' event, in which we only see that - // space was entered. - var data = e.data; - if (data.length == 1 && data[0] === ' ') { - map._docLayer._postKeyboardEvent('input', data[0].charCodeAt(), 0); - } + this._textData = e.data; this._textArea.value = ''; } @@ -179,8 +166,25 @@ L.Control.MobileInput = L.Control.extend({ }, onInput: function (e) { + console.log('onInput: e.inputType === ' + e.inputType); + var backSpace = this._map.keyboard._toUNOKeyCode(8); - if (e.inputType && e.inputType === 'deleteContentBackward' && this._lastInput !== backSpace) { + // deferred processing of composition text or normal text; we can get + // both in some cases, and based on the input event we need to decide + // which one we actually need to use + if (e.inputType === 'insertText') { + if (this._textData) { + for (var i = 0; i < this._textData.length; ++i) { + map._docLayer._postKeyboardEvent('input', this._textData[i].charCodeAt(), 0); + } + } + } + else if (e.inputType === 'insertCompositionText') { + if (this._composingData) { + map._docLayer._postCompositionEvent(0, 'input', this._composingData); + } + } + else if (e.inputType === 'deleteContentBackward' && this._lastInput !== backSpace) { // this means we need to delete the entire interim composition; // let's issue backspace that many times if (this._composingData) { @@ -189,6 +193,7 @@ L.Control.MobileInput = L.Control.extend({ } } } + L.DomEvent.stopPropagation(e); } }); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
