loleaflet/src/control/Control.MobileInput.js |   35 ++++++++++++++++-----------
 1 file changed, 22 insertions(+), 13 deletions(-)

New commits:
commit f42e0bb4d1c99c1d229a638e59061ef7985d01e8
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Wed Oct 3 21:52:59 2018 +0200
Commit:     Aron Budea <aron.bu...@collabora.com>
CommitDate: Thu Oct 4 01:05:46 2018 +0200

    android chrome: Stop composing when we get an actual key event.
    
    So that it is possible to press Enter while still in composition.
    It is necessary to stop the composing itself, because otherwise the word
    gets duplicated on the new line as soon as the user presses a key.
    
    Change-Id: I78951a423715e71533f1a73d5bbe3b0f0f05e6cd
    Reviewed-on: https://gerrit.libreoffice.org/61334
    Reviewed-by: Aron Budea <aron.bu...@collabora.com>
    Tested-by: Aron Budea <aron.bu...@collabora.com>

diff --git a/loleaflet/src/control/Control.MobileInput.js 
b/loleaflet/src/control/Control.MobileInput.js
index 3fab3bf56..94084371b 100644
--- a/loleaflet/src/control/Control.MobileInput.js
+++ b/loleaflet/src/control/Control.MobileInput.js
@@ -88,10 +88,19 @@ 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) {
+                               return;
+                       }
+                       // stop the composing - so that we handle eg. Enter 
even during
+                       // composition
+                       this._isComposing = false;
                        this._lastInput = null;
-                       return;
+                       this._textArea.value = '';
                }
 
                docLayer._resetPreFetching();
commit f176bb1e81b5f3769cb56752c7102f93f2eca024
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Wed Oct 3 19:46:07 2018 +0200
Commit:     Aron Budea <aron.bu...@collabora.com>
CommitDate: Thu Oct 4 01:05:37 2018 +0200

    android chrome: We have to delete the interim results sometimes.
    
    When we are autocorrecting a word, we get a deleteContentBackward event;
    in that case we have to delete everything we have composed so far.
    
    Change-Id: I36f3d1afcb9b74ac75dee7d64832cc5a3d346045
    Reviewed-on: https://gerrit.libreoffice.org/61333
    Reviewed-by: Aron Budea <aron.bu...@collabora.com>
    Tested-by: Aron Budea <aron.bu...@collabora.com>

diff --git a/loleaflet/src/control/Control.MobileInput.js 
b/loleaflet/src/control/Control.MobileInput.js
index 25b0addff..3fab3bf56 100644
--- a/loleaflet/src/control/Control.MobileInput.js
+++ b/loleaflet/src/control/Control.MobileInput.js
@@ -128,14 +128,13 @@ 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
-                       var txt = '';
-                       for (var i = 0; i < e.data.length; i++) {
-                               txt += e.data[i];
-                       }
-                       if (txt) {
-                               map._docLayer._postCompositionEvent(0, 'input', 
txt);
+                       this._composingData = e.data; // cache what we have 
composed so far
+                       if (e.data) {
+                               map._docLayer._postCompositionEvent(0, 'input', 
e.data);
                        }
                }
 
@@ -152,11 +151,6 @@ L.Control.MobileInput = L.Control.extend({
                        // code 229 when hitting space (as with all composiiton 
events)
                        // with addition to 'textinput' event, in which we only 
see that
                        // space was entered.
-                       //
-                       // TODO: Maybe make sure this is only triggered when 
keydown has
-                       // 229 code. Also we need to detect that composition 
was overriden
-                       // (part or whole word deleted) with the spell-checked 
word. (for
-                       // example: enter 'tar' and with spell-check correct 
that to 'rat')
                        var data = e.data;
                        if (data.length == 1 && data[0] === ' ') {
                                map._docLayer._postKeyboardEvent('input', 
data[0].charCodeAt(), 0);
@@ -169,7 +163,13 @@ L.Control.MobileInput = L.Control.extend({
        onInput: function (e) {
                var backSpace = this._map.keyboard._toUNOKeyCode(8);
                if (e.inputType && e.inputType === 'deleteContentBackward' && 
this._lastInput !== backSpace) {
-                       this._map._docLayer._postKeyboardEvent('input', 0, 
backSpace);
+                       // this means we need to delete the entire interim 
composition;
+                       // let's issue backspace that many times
+                       if (this._composingData) {
+                               for (var i = 0; i < this._composingData.length; 
++i) {
+                                       
this._map._docLayer._postKeyboardEvent('input', 0, backSpace);
+                               }
+                       }
                }
                L.DomEvent.stopPropagation(e);
        }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to