loleaflet: Don't forward shift+insert/delete key events

This are converted to 'cut', 'paste' events which are
automatically handled by us using uno commands, so avoid
double-handling them.

Change-Id: If97e9f4efabbb929e7a5dd87c1228ee6a0df9e61
This commit is contained in:
Pranav Kant 2017-01-05 13:13:20 +05:30
parent 053f5b5d9f
commit 5374b6c6ff

View file

@ -119,7 +119,7 @@ L.Map.Keyboard = L.Handler.extend({
222 : null // single quote : UNKOWN 222 : null // single quote : UNKOWN
}, },
handleOnKeyDown: { handleOnKeyDownKeys: {
// these keys need to be handled on keydown in order for them // these keys need to be handled on keydown in order for them
// to work on chrome // to work on chrome
8 : true, // backspace 8 : true, // backspace
@ -180,6 +180,19 @@ L.Map.Keyboard = L.Handler.extend({
this._map.off('compositionstart compositionupdate compositionend textInput', this._onKeyDown, this); this._map.off('compositionstart compositionupdate compositionend textInput', this._onKeyDown, this);
}, },
_handleOnKeyDown: function (keyCode, modifier) {
if (modifier & this.keyModifier.shift) {
// 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 this.handleOnKeyDownKeys[keyCode];
},
_setPanOffset: function (pan) { _setPanOffset: function (pan) {
var keys = this._panKeys = {}, var keys = this._panKeys = {},
codes = this.navigationKeyCodes, codes = this.navigationKeyCodes,
@ -295,12 +308,12 @@ L.Map.Keyboard = L.Handler.extend({
this._keyHandled = false; this._keyHandled = false;
this._bufferedTextInputEvent = null; this._bufferedTextInputEvent = null;
if (this.handleOnKeyDown[keyCode] && charCode === 0) { if (this._handleOnKeyDown(keyCode, this.modifier) && charCode === 0) {
docLayer._postKeyboardEvent('input', charCode, unoKeyCode); docLayer._postKeyboardEvent('input', charCode, unoKeyCode);
} }
} }
else if ((e.type === 'keypress' || e.type === 'compositionend') && else if ((e.type === 'keypress' || e.type === 'compositionend') &&
(!this.handleOnKeyDown[keyCode] || charCode !== 0)) { (!this._handleOnKeyDown(keyCode, this.modifier) || charCode !== 0)) {
if (charCode === keyCode && charCode !== 13) { if (charCode === keyCode && charCode !== 13) {
// Chrome sets keyCode = charCode for printable keys // Chrome sets keyCode = charCode for printable keys
// while LO requires it to be 0 // while LO requires it to be 0