Merge pull request #2241 from BeksOmega/fixes/DisabledContentsBlocks

RetrieveDisabled Blocks from the Trashcan
This commit is contained in:
Rachel Fenichel
2019-01-28 16:47:53 -08:00
committed by GitHub
3 changed files with 18 additions and 2 deletions

View File

@@ -595,6 +595,18 @@ Blockly.Flyout.prototype.onMouseDown_ = function(e) {
}
};
/**
* Does this flyout allow you to create a new instance of the given block?
* Used for deciding if a block can be "dragged out of" the flyout.
* @param {!Blockly.BlockSvg} block The block to copy from the flyout.
* @return {!boolean} True if you can create a new instance of the block, false
* otherwise.
* @package
*/
Blockly.Flyout.prototype.isBlockCreatable_ = function(block) {
return !block.disabled;
};
/**
* Create a copy of this block on the workspace.
* @param {!Blockly.BlockSvg} originalBlock The block to copy from the flyout.

View File

@@ -327,8 +327,7 @@ Blockly.Gesture.prototype.updateDragDelta_ = function(currentXY) {
* @private
*/
Blockly.Gesture.prototype.updateIsDraggingFromFlyout_ = function() {
// Disabled blocks may not be dragged from the flyout.
if (this.targetBlock_.disabled) {
if (!this.flyout_.isBlockCreatable_(this.targetBlock_)) {
return false;
}
if (!this.flyout_.isScrollable() ||

View File

@@ -282,6 +282,11 @@ Blockly.Trashcan.prototype.init = function(verticalSpacing) {
Blockly.utils.insertAfter(this.flyout_.createDom('svg'),
this.workspace_.getParentSvg());
this.flyout_.init(this.workspace_);
this.flyout_.isBlockCreatable_ = function() {
// All blocks, including disabled ones, can be dragged from the
// trashcan flyout.
return true;
};
}
this.verticalSpacing_ = this.MARGIN_BOTTOM_ + verticalSpacing;