mirror of
https://github.com/google/blockly.git
synced 2026-03-09 23:00:10 +01:00
Merge pull request #1752 from samelhusseini/develop_unplugblock
Snap a single block from a stack (if meta key is pressed)
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user