[Libreoffice-commits] online.git: loleaflet/src
Pranav Kant
pranavk at collabora.co.uk
Fri Mar 16 07:29:21 UTC 2018
loleaflet/src/map/handler/Map.Keyboard.js | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
New commits:
commit 8a713ec7a56c6dfa176e64177a870a14e7209758
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Mon Mar 12 17:41:36 2018 +0530
loleaflet: firefox emits 'keypress' for shift+insert too
So, we need to ignore the key event in the start of the handler.
Otherwise, in the case of firefox, us ignoring it in 'keydown' gets it
handled in 'keypress' which does double copy/paste.
Change-Id: I93f0e5c7db8817fab42764d0f0d3b12b50d62f81
Reviewed-on: https://gerrit.libreoffice.org/51134
Reviewed-by: pranavk <pranavk at collabora.co.uk>
Tested-by: pranavk <pranavk at collabora.co.uk>
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index 5f63b4473..aade802a0 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -182,17 +182,16 @@ L.Map.Keyboard = L.Handler.extend({
this._map.off('compositionstart compositionupdate compositionend textInput', this._onKeyDown, this);
},
- _handleOnKeyDown: function (keyCode, modifier) {
- if (modifier & this.keyModifier.shift) {
+ _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
- if (keyCode === 45 || keyCode === 46) {
- return false;
- }
+ return true;
}
- return this.handleOnKeyDownKeys[keyCode];
+ return false;
},
_setPanOffset: function (pan) {
@@ -336,16 +335,19 @@ L.Map.Keyboard = L.Handler.extend({
if (this._map._permission === 'edit') {
docLayer._resetPreFetching();
- if (e.type === 'keydown') {
+ if (this._ignoreKeyEvent(e)) {
+ // key ignored
+ }
+ else if (e.type === 'keydown') {
this._keyHandled = false;
this._bufferedTextInputEvent = null;
- if (this._handleOnKeyDown(keyCode, this.modifier) && charCode === 0) {
+ if (this.handleOnKeyDownKeys[keyCode] && charCode === 0) {
keyEventFn('input', charCode, unoKeyCode);
}
}
else if ((e.type === 'keypress' || e.type === 'compositionend') &&
- (!this._handleOnKeyDown(keyCode, this.modifier) || charCode !== 0)) {
+ (!this.handleOnKeyDownKeys[keyCode] || charCode !== 0)) {
if (charCode === keyCode && charCode !== 13) {
// Chrome sets keyCode = charCode for printable keys
// while LO requires it to be 0
More information about the Libreoffice-commits
mailing list