diff --git a/core/block_dragger.js b/core/block_dragger.js index 051b2a6d8..dd1feba98 100644 --- a/core/block_dragger.js +++ b/core/block_dragger.js @@ -144,9 +144,10 @@ Blockly.BlockDragger.initIconData_ = function(block) { * Start dragging a block. This includes moving it to the drag surface. * @param {!goog.math.Coordinate} currentDragDeltaXY How far the pointer has * moved from the position at mouse down, in pixel units. + * @param {boolean} healStack whether or not to heal the stack after disconnecting * @package */ -Blockly.BlockDragger.prototype.startBlockDrag = function(currentDragDeltaXY) { +Blockly.BlockDragger.prototype.startBlockDrag = function(currentDragDeltaXY, healStack) { if (!Blockly.Events.getGroup()) { Blockly.Events.setGroup(true); } @@ -154,8 +155,10 @@ Blockly.BlockDragger.prototype.startBlockDrag = function(currentDragDeltaXY) { this.workspace_.setResizesEnabled(false); Blockly.BlockSvg.disconnectUiStop_(); - if (this.draggingBlock_.getParent()) { - this.draggingBlock_.unplug(); + if (this.draggingBlock_.getParent() || + (healStack && this.draggingBlock_.nextConnection && + this.draggingBlock_.nextConnection.targetBlock())) { + this.draggingBlock_.unplug(healStack); var delta = this.pixelsToWorkspaceUnits_(currentDragDeltaXY); var newLoc = goog.math.Coordinate.sum(this.startXY_, delta); diff --git a/core/gesture.js b/core/gesture.js index 26e85ada9..070e94ac7 100644 --- a/core/gesture.js +++ b/core/gesture.js @@ -225,6 +225,14 @@ Blockly.Gesture = function(e, creatorWorkspace) { * @private */ this.isEnding_ = false; + + /** + * Boolean used to indicate whether or not to heal the stack after + * disconnecting a block. + * @type {boolean} + * @private + */ + this.healStack_ = !Blockly.DRAG_STACK; }; /** @@ -443,7 +451,7 @@ Blockly.Gesture.prototype.updateIsDragging_ = function() { Blockly.Gesture.prototype.startDraggingBlock_ = function() { this.blockDragger_ = new Blockly.BlockDragger(this.targetBlock_, this.startWorkspace_); - this.blockDragger_.startBlockDrag(this.currentDragDeltaXY_); + this.blockDragger_.startBlockDrag(this.currentDragDeltaXY_, this.healStack_); this.blockDragger_.dragBlock(this.mostRecentEvent_, this.currentDragDeltaXY_); }; @@ -503,6 +511,7 @@ Blockly.Gesture.prototype.doStart = function(e) { } this.mouseDownXY_ = new goog.math.Coordinate(e.clientX, e.clientY); + this.healStack_ = e.altKey || e.ctrlKey || e.metaKey; this.bindMouseEvents(e); };