From 4e80d7cb0c8d71463ace331aff76a7988378d63c Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 6 Oct 2021 19:24:08 +0200 Subject: [PATCH] added method to check whether an arbitrary block is hidden in the palette --- HISTORY.md | 1 + src/objects.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 98a08fd7..9632dc0c 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -43,6 +43,7 @@ * threads: keep hidden variables out of the palette and drop-down menus * objects: added utilities to enumerate all palette blocks for hiding & showing * objects, threads, extensions: refactored block hiding methods +* objects: added method to check whether an arbitrary block is hidden in the palette ### 2021-10-05 * threads, store: added infrastructure for hiding individual variables in palette diff --git a/src/objects.js b/src/objects.js index 3fd1b042..bc7771f6 100644 --- a/src/objects.js +++ b/src/objects.js @@ -3248,6 +3248,19 @@ SpriteMorph.prototype.allPaletteBlocks = function () { return blocks.filter(each => each instanceof BlockMorph); }; +SpriteMorph.prototype.isHidingBlock = function (aBlock) { + if (aBlock.isCustomBlock) { + return ( + aBlock.isGlobal ? aBlock.definition + : this.getLocalMethod(aBlock.semanticSpec) + ).isHelper; + } + if (aBlock.selector === 'reportGetVar') { + return this.variables.find(name).vars[aBlock.blockSpec].isHidden; + } + return StageMorph.prototype.hiddenPrimitives[aBlock.selector] === true; +}; + SpriteMorph.prototype.changeBlockVisibility = function (aBlock, hideIt) { if (aBlock.isCustomBlock) { this.changeCustomBlockVisibility(aBlock, hideIt); @@ -9394,6 +9407,8 @@ StageMorph.prototype.searchBlocks = SpriteMorph.prototype.searchBlocks; StageMorph.prototype.allPaletteBlocks = SpriteMorph.prototype.allPaletteBlocks; +StageMorph.prototype.isHidingBlock = SpriteMorph.prototype.isHidingBlock; + StageMorph.prototype.changeBlockVisibility = SpriteMorph.prototype.changeBlockVisibility;