ruler: insert tabstop from a context menu (right click)

Change-Id: I0699b53a6972b304f358948d49619a5004329eff
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92548
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
Tomaž Vajngerl 2020-04-20 09:28:25 +02:00 committed by Tomaž Vajngerl
parent 54461e0e1a
commit e11202ea49

View file

@ -388,11 +388,7 @@ L.Control.Ruler = L.Control.extend({
_initiateTabstopDrag: function(event) { _initiateTabstopDrag: function(event) {
// console.log('===> _initiateTabstopDrag ' + event.type); // console.log('===> _initiateTabstopDrag ' + event.type);
if (event.button !== 0) {
event.stopPropagation(); // prevent handling of the mother event elsewhere
return;
}
var tabstopContainer = null; var tabstopContainer = null;
var pointX = null; var pointX = null;
@ -405,6 +401,28 @@ L.Control.Ruler = L.Control.extend({
pointX = event.layerX; pointX = event.layerX;
} }
if (event.button === 2) {
this.currentPositionInTwips = this._map._docLayer._pixelsToTwips({x: pointX, y:0}).x;
$.contextMenu({
selector: '.loleaflet-ruler-tabstopcontainer',
className: 'loleaflet-font',
items: {
inserttabstop: {
name: _('Insert tabstop'),
callback: (this._insertTabstop).bind(this)
}
}
});
event.stopPropagation();
return;
}
else if (event.button !== 0) {
event.stopPropagation(); // prevent handling of the mother event elsewhere
return;
}
// check if we hit any tabstop // check if we hit any tabstop
var tabstop = null; var tabstop = null;
var margin = 10; var margin = 10;
@ -423,18 +441,6 @@ L.Control.Ruler = L.Control.extend({
} }
if (tabstop == null) { if (tabstop == null) {
var positionTwip = this._map._docLayer._pixelsToTwips({x: pointX, y:0}).x;
var params = {
Index: {
type : 'int32',
value : -1
},
Position: {
type : 'int32',
value : positionTwip
}
};
this._map.sendUnoCommand('.uno:ChangeTabStop', params);
return; return;
} }
@ -506,6 +512,22 @@ L.Control.Ruler = L.Control.extend({
L.DomEvent.off(this._rTSContainer, 'mouseout', this._endTabstopDrag, this); L.DomEvent.off(this._rTSContainer, 'mouseout', this._endTabstopDrag, this);
}, },
_insertTabstop: function() {
if (this.currentPositionInTwips != null) {
var params = {
Index: {
type : 'int32',
value : -1
},
Position: {
type : 'int32',
value : this.currentPositionInTwips
}
};
this._map.sendUnoCommand('.uno:ChangeTabStop', params);
}
},
}); });