diff --git a/browser/src/control/Control.FormulaBar.js b/browser/src/control/Control.FormulaBar.js index ad825ead1..2e3e98a5b 100644 --- a/browser/src/control/Control.FormulaBar.js +++ b/browser/src/control/Control.FormulaBar.js @@ -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); } }); diff --git a/browser/src/control/Control.FormulaBarJSDialog.js b/browser/src/control/Control.FormulaBarJSDialog.js index 40654d667..3cd411d7f 100644 --- a/browser/src/control/Control.FormulaBarJSDialog.js +++ b/browser/src/control/Control.FormulaBarJSDialog.js @@ -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; diff --git a/browser/src/control/Toolbar.js b/browser/src/control/Toolbar.js index 654fbc3ba..2c65e451a 100644 --- a/browser/src/control/Toolbar.js +++ b/browser/src/control/Toolbar.js @@ -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':