formula bar: handling shift+enter correctly

In desktop shift + enter is used for inserting a new line (multiline
formula input box).
This patch makes that works for tunneled formula bar too.

Change-Id: Ib1b3fd6593b6361c725cff606925d110c8ac1c83
Reviewed-on: https://gerrit.libreoffice.org/84170
Reviewed-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Tested-by: Marco Cecchetti <marco.cecchetti@collabora.com>
This commit is contained in:
Marco Cecchetti 2019-11-29 17:01:59 +01:00
parent 836ce7d636
commit b228a160b9
2 changed files with 16 additions and 4 deletions

View file

@ -17,6 +17,10 @@ L.TextInput = L.Layer.extend({
// pressed sometimes - consider ' foo' -> ' foo'
this._deleteHint = ''; // or 'delete' or 'backspace'
// We need to detect line break in the tunneled formula
// input window for the multiline case.
this._linebreakHint = false;
// Clearing the area can generate input events
this._ignoreInputCount = 0;
@ -461,8 +465,12 @@ L.TextInput = L.Layer.extend({
this._lastContent = content;
if (newText.length > 0)
if (this._linebreakHint && this._map.dialog._calcInputBar &&
this._map.getWinId() === this._map.dialog._calcInputBar.id) {
this._sendKeyEvent(13, 5376);
} else if (newText.length > 0) {
this._sendText(String.fromCharCode.apply(null, newText));
}
// was a 'delete' and we need to reset world.
if (removeAfter > 0)
@ -570,12 +578,14 @@ L.TextInput = L.Layer.extend({
},
_onKeyDown: function _onKeyDown(ev) {
if (ev.keyCode == 8)
if (ev.keyCode === 8)
this._deleteHint = 'backspace';
else if (ev.keyCode == 46)
else if (ev.keyCode === 46)
this._deleteHint = 'delete';
else
else {
this._deleteHint = '';
this._linebreakHint = ev.keyCode === 13 && ev.shiftKey;
}
},
// Check arrow keys on 'keyup' event; using 'ArrowLeft' or 'ArrowRight'

View file

@ -812,6 +812,8 @@ L.Map = L.Evented.extend({
// the main document) has the actual focus. 0 means the document.
setWinId: function (id) {
console.log('winId set to: ' + id);
if (typeof id === 'string')
id = parseInt(id);
this._winId = id;
},