mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-20 18:09:43 -04:00
parent
f1977ded18
commit
f23100c52a
2 changed files with 7 additions and 4 deletions
|
@ -487,12 +487,15 @@ Blockly.Block.prototype.setParent = function(newParent) {
|
|||
* Includes this block in the list.
|
||||
* Includes value and block inputs, as well as any following statements.
|
||||
* Excludes any connection on an output tab or any preceding statements.
|
||||
* @param {boolean=} opt_ignoreShadows If set, don't include shadow blocks.
|
||||
* @return {!Array.<!Blockly.Block>} Flattened array of blocks.
|
||||
*/
|
||||
Blockly.Block.prototype.getDescendants = function() {
|
||||
Blockly.Block.prototype.getDescendants = function(opt_ignoreShadows) {
|
||||
var blocks = [this];
|
||||
for (var child, x = 0; child = this.childBlocks_[x]; x++) {
|
||||
blocks.push.apply(blocks, child.getDescendants());
|
||||
if (!opt_ignoreShadows || !child.isShadow_) {
|
||||
blocks.push.apply(blocks, child.getDescendants(opt_ignoreShadows));
|
||||
}
|
||||
}
|
||||
return blocks;
|
||||
};
|
||||
|
|
|
@ -751,11 +751,11 @@ Blockly.BlockSvg.prototype.showContextMenu_ = function(e) {
|
|||
|
||||
// Option to delete this block.
|
||||
// Count the number of blocks that are nested in this block.
|
||||
var descendantCount = this.getDescendants().length;
|
||||
var descendantCount = this.getDescendants(true).length;
|
||||
var nextBlock = this.getNextBlock();
|
||||
if (nextBlock) {
|
||||
// Blocks in the current stack would survive this block's deletion.
|
||||
descendantCount -= nextBlock.getDescendants().length;
|
||||
descendantCount -= nextBlock.getDescendants(true).length;
|
||||
}
|
||||
var deleteOption = {
|
||||
text: descendantCount == 1 ? Blockly.Msg.DELETE_BLOCK :
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue