allow custom draggable checks.
This commit is contained in:
parent
3205dd289d
commit
1044a88e58
|
@ -109,7 +109,9 @@ var bottomright = blessed.terminal({
|
||||||
});
|
});
|
||||||
|
|
||||||
[topleft, topright, bottomleft, bottomright].forEach(function(term) {
|
[topleft, topright, bottomleft, bottomright].forEach(function(term) {
|
||||||
term.enableDrag();
|
term.enableDrag(function(mouse) {
|
||||||
|
return !!mouse.ctrl;
|
||||||
|
});
|
||||||
term.on('title', function(title) {
|
term.on('title', function(title) {
|
||||||
screen.title = title;
|
screen.title = title;
|
||||||
});
|
});
|
||||||
|
|
|
@ -3026,18 +3026,23 @@ Element.prototype.__defineGetter__('draggable', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
Element.prototype.__defineSetter__('draggable', function(draggable) {
|
Element.prototype.__defineSetter__('draggable', function(draggable) {
|
||||||
return draggable ? this.enableDrag() : this.disableDrag();
|
return draggable ? this.enableDrag(draggable) : this.disableDrag();
|
||||||
});
|
});
|
||||||
|
|
||||||
Element.prototype.enableDrag = function() {
|
Element.prototype.enableDrag = function(verify) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (this._draggable) return true;
|
if (this._draggable) return true;
|
||||||
|
|
||||||
|
if (typeof verify !== 'function') {
|
||||||
|
verify = function() { return true; };
|
||||||
|
}
|
||||||
|
|
||||||
this.enableMouse();
|
this.enableMouse();
|
||||||
|
|
||||||
this.on('mousedown', this._dragMD = function(data) {
|
this.on('mousedown', this._dragMD = function(data) {
|
||||||
if (self.screen._dragging) return;
|
if (self.screen._dragging) return;
|
||||||
|
if (!verify(data)) return;
|
||||||
self.screen._dragging = self;
|
self.screen._dragging = self;
|
||||||
self._drag = {
|
self._drag = {
|
||||||
x: data.x - self.aleft,
|
x: data.x - self.aleft,
|
||||||
|
|
Loading…
Reference in New Issue