formulabar: use uno command not key input to accept formula

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I9c4d5b12df70579adf54e0bf833048315ec98f6e
This commit is contained in:
Szymon Kłos 2022-04-26 18:14:48 +02:00 committed by Szymon Kłos
parent 3db9ba06d1
commit 475b62cdb1
3 changed files with 39 additions and 13 deletions

View file

@ -148,6 +148,9 @@ L.Map.include({
mobileTopBar.hide('undo');
mobileTopBar.hide('redo');
jsdialogFormulabar.hide('startformula');
jsdialogFormulabar.hide('AutoSumMenu');
},
onFormulaBarBlur: function() {
@ -156,6 +159,7 @@ L.Map.include({
// once hidden, click event won't be processed.
// TODO: Some better way to do it ?
var map = this;
setTimeout(function() {
if ($('.leaflet-cursor').is(':visible'))
return;
@ -168,6 +172,9 @@ L.Map.include({
mobileTopBar.show('undo');
mobileTopBar.show('redo');
jsdialogFormulabar.show('startformula');
jsdialogFormulabar.show('AutoSumMenu');
}, 250);
}
});

View file

@ -93,11 +93,17 @@ L.Control.FormulaBarJSDialog = L.Control.extend({
focus: function() {
setTimeout(function() {
var input = document.getElementById('sc_input_window');
if (document.activeElement !== input)
if (input && document.activeElement !== input)
input.focus();
}, 0);
},
blur: function() {
var input = document.getElementById('sc_input_window');
if (input)
input.blur();
},
hasFocus: function() {
var input = document.getElementById('sc_input_window');
return document.activeElement === input;

View file

@ -757,30 +757,43 @@ L.Map.include({
map.fire('postMessage', {msgId: 'UI_SaveAs'});
},
formulabarBlur: function() {
if (!window.mode.isMobile()) {
var hasJSDialogOpened = this.jsdialog && this.jsdialog.hasDialogOpened();
var hasVexOpened = Object.keys(vex.getAll()).length > 0;
if (!hasVexOpened && !hasJSDialogOpened)
this.focus();
}
},
formulabarFocus: function() {
if (!window.mode.isMobile())
this.formulabar.focus();
},
// map.dispatch() will be used to call some actions so we can share the code
dispatch: function(action) {
switch (action) {
case 'acceptformula':
{
// focus on map, and press enter
this.focus();
this._docLayer.postKeyboardEvent('input',
this.keyboard.keyCodes.enter,
this.keyboard._toUNOKeyCode(this.keyboard.keyCodes.enter));
if (window.mode.isMobile()) {
w2ui['actionbar'].hide('acceptformula', 'cancelformula');
w2ui['actionbar'].show('undo', 'redo');
this.focus();
this._docLayer.postKeyboardEvent('input',
this.keyboard.keyCodes.enter,
this.keyboard._toUNOKeyCode(this.keyboard.keyCodes.enter));
} else {
this.sendUnoCommand('.uno:AcceptFormula');
}
this.onFormulaBarBlur();
this.formulabarBlur();
}
break;
case 'cancelformula':
{
this.sendUnoCommand('.uno:Cancel');
if (window.mode.isMobile()) {
w2ui['actionbar'].hide('acceptformula', 'cancelformula');
w2ui['actionbar'].show('undo', 'redo');
}
this.onFormulaBarBlur();
this.formulabarBlur();
}
break;
case 'functiondialog':