[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4-0-4' - loleaflet/src
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri May 3 11:53:07 UTC 2019
loleaflet/src/map/handler/Map.Keyboard.js | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
New commits:
commit 857a0181cff347de976b903a7a98929b1dcb7d7e
Author: Iván Sánchez Ortega <ivan.sanchez at collabora.com>
AuthorDate: Thu May 2 09:28:55 2019 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Fri May 3 13:52:48 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/71736
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at 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) {
More information about the Libreoffice-commits
mailing list