diff --git a/example/multiplex.js b/example/multiplex.js index 81f2a4b..536f3c7 100755 --- a/example/multiplex.js +++ b/example/multiplex.js @@ -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; }); diff --git a/lib/widget.js b/lib/widget.js index 8b2a114..1634297 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -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,