allow custom draggable checks.

This commit is contained in:
Christopher Jeffrey 2015-05-01 22:14:49 -07:00
parent 3205dd289d
commit 1044a88e58
2 changed files with 10 additions and 3 deletions

View File

@ -109,7 +109,9 @@ var bottomright = blessed.terminal({
});
[topleft, topright, bottomleft, bottomright].forEach(function(term) {
term.enableDrag();
term.enableDrag(function(mouse) {
return !!mouse.ctrl;
});
term.on('title', function(title) {
screen.title = title;
});

View File

@ -3026,18 +3026,23 @@ Element.prototype.__defineGetter__('draggable', function() {
});
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;
if (this._draggable) return true;
if (typeof verify !== 'function') {
verify = function() { return true; };
}
this.enableMouse();
this.on('mousedown', this._dragMD = function(data) {
if (self.screen._dragging) return;
if (!verify(data)) return;
self.screen._dragging = self;
self._drag = {
x: data.x - self.aleft,