[SSE] Improvement for textbox

This commit is contained in:
Alexei Koshelev 2022-10-06 00:01:02 +03:00
parent 15f495ee58
commit 857578864d
2 changed files with 54 additions and 10 deletions

View file

@ -255,7 +255,10 @@ define([
this.onApiEndAddShape = function() {
if (this.toolbar.btnInsertShape.pressed) this.toolbar.btnInsertShape.toggle(false, true);
if (this.toolbar.btnInsertText.pressed) this.toolbar.btnInsertText.toggle(false, true);
if (this.toolbar.btnInsertText.pressed) {
this.toolbar.btnInsertText.toggle(false, true);
this.toolbar.btnInsertText.menu.clearAll();
}
$(document.body).off('mouseup', checkInsertAutoshape);
};
},
@ -401,10 +404,7 @@ define([
toolbar.btnInsertImage.menu.on('item:click', _.bind(this.onInsertImageMenu, this));
toolbar.btnInsertHyperlink.on('click', _.bind(this.onHyperlink, this));
toolbar.btnInsertText.on('click', _.bind(this.onBtnInsertTextClick, this));
toolbar.btnInsertText.menu.on('item:click', _.bind(function(btn, e) {
this.toolbar.btnInsertText.toggle(true);
this.onBtnInsertTextClick(e.value, btn, e);
}, this));
toolbar.btnInsertText.menu.on('item:click', _.bind(this.onMenuInsertTextClick, this));
toolbar.btnInsertShape.menu.on('hide:after', _.bind(this.onInsertShapeHide, this));
toolbar.btnInsertEquation.on('click', _.bind(this.onInsertEquationClick, this));
toolbar.btnInsertSymbol.on('click', _.bind(this.onInsertSymbolClick, this));
@ -1251,7 +1251,34 @@ define([
}
},
onBtnInsertTextClick: function(type, btn, e) {
onBtnInsertTextClick: function(btn, e) {
btn.menu.items.forEach(function(item) {
if(item.value == btn.options.textboxType)
item.setChecked(true);
});
if(!this.toolbar.btnInsertText.pressed) {
this.toolbar.btnInsertText.menu.clearAll();
}
this.onInsertText(btn.options.textboxType, btn, e);
},
onMenuInsertTextClick: function(btn, e) {
var oldType = this.toolbar.btnInsertText.options.textboxType;
var newType = e.value;
this.toolbar.btnInsertText.toggle(true);
if(newType != oldType){
this.toolbar.btnInsertText.changeIcon({
next: e.options.iconClsForMainBtn,
curr: this.toolbar.btnInsertText.menu.items.filter(function(item){return item.value == oldType})[0].options.iconClsForMainBtn
});
this.toolbar.btnInsertText.updateHint([e.caption, this.views.Toolbar.prototype.tipInsertText]);
this.toolbar.btnInsertText.options.textboxType = newType;
}
this.onInsertText(newType, btn, e);
},
onInsertText: function(type, btn, e) {
if (this.api)
this._addAutoshape(this.toolbar.btnInsertText.pressed, type);

View file

@ -1225,14 +1225,15 @@ define([
me.btnInsertText = new Common.UI.Button({
id : 'tlbtn-inserttext',
cls : 'btn-toolbar x-huge icon-top',
iconCls : 'toolbar__icon btn-text',
iconCls : 'toolbar__icon btn-subtotals',
caption : me.capInsertText,
lock : [_set.editCell, _set.lostConnect, _set.coAuth, _set['Objects']],
enableToggle: true,
split : true,
dataHint : '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
dataHintOffset: 'small',
textboxType: 'textRect',
});
me.btnInsertTextArt = new Common.UI.Button({
@ -2585,8 +2586,24 @@ define([
if(this.btnInsertText) {
this.btnInsertText.setMenu(new Common.UI.Menu({
items: [
{caption: this.tipInsertHorizontalText, value: 'textRect'},
{caption: this.tipInsertVerticalText, value: 'textRectVertical'},
{
caption: this.tipInsertHorizontalText,
checkable: true,
checkmark: false,
iconCls : 'menu__icon text-orient-hor',
toggleGroup: 'textbox',
value: 'textRect',
iconClsForMainBtn: 'btn-subtotals'
},
{
caption: this.tipInsertVerticalText,
checkable: true,
checkmark: false,
iconCls : 'menu__icon text-orient-rup',
toggleGroup: 'textbox',
value: 'textRectVertical',
iconClsForMainBtn: 'btn-pivot-layout'
},
]
}));
}