loleaflet/src/map/handler/Map.Keyboard.js |   23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

New commits:
commit 3a30ac379948dfc903883cd2549103d6126b7784
Author:     Iván Sánchez Ortega <ivan.sanc...@collabora.com>
AuthorDate: Thu May 2 09:28:55 2019 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Fri May 3 13:53:02 2019 +0200

    tdf#124749:loleaflet: use "KeyboardEvent.key" to detect ignored key events
    
    Replace KeyboardEvent.keyCode with KeyboardEvent.key for detection of 
"Delete" and
    "Insert" keys. keyCode misbehaves when using an AZERTY/DVORAK keyboard 
layout, e.g.
    the keyCode for "Delete" in QWERTY is the same as "." in AZERTY.
    
    This works on all major browsers, the only outlier being MSIE8:
    
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key#Browser_compatibility
    
    Change-Id: I5cbfa18ef59ab4989a866fdf4b5708610beccaad
    Reviewed-on: https://gerrit.libreoffice.org/71735
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>
    Tested-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/loleaflet/src/map/handler/Map.Keyboard.js 
b/loleaflet/src/map/handler/Map.Keyboard.js
index 28144cc53..863473bae 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -182,16 +182,23 @@ L.Map.Keyboard = L.Handler.extend({
                this._map.off('compositionstart compositionupdate 
compositionend textInput', this._onIME, this);
        },
 
+       /*
+        * Returns true whenever the key event shall be ignored.
+        * This means shift+insert and shift+delete (or "insert or delete when 
holding
+        * shift down"). Those events are handled elsewhere to trigger "cut" 
and 
+        * "paste" events, and need to be ignored in order to avoid 
double-handling them.
+        */
        _ignoreKeyEvent: function(e) {
-               var shift = e.originalEvent.shiftKey ? this.keyModifier.shift : 
0;
-               if (shift && (e.originalEvent.keyCode === 45 || 
e.originalEvent.keyCode === 46)) {
-                       // don't handle shift+insert, shift+delete
-                       // These are converted to 'cut', 'paste' events which 
are
-                       // automatically handled by us, so avoid double-handling
-                       return true;
+               var shift = e.originalEvent.shiftKey;
+               if ('key' in e.originalEvent) {
+                       var key = e.originalEvent.key;
+                       return (shift && (key === 'Delete' || key === 
'Insert'));
+               } else {
+                       // keyCode is not reliable in AZERTY/DVORAK keyboard 
layouts, is used
+                       // only as a fallback for MSIE8.
+                       var keyCode = e.originalEvent.keyCode;
+                       return (shift && (keyCode === 45 || keyCode === 46));
                }
-
-               return false;
        },
 
        _setPanOffset: function (pan) {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to