diff --git a/HISTORY.md b/HISTORY.md index fd34841c..0d1c7d94 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -37,6 +37,9 @@ * German * Chinese, thanks, Simon! +### 2021-10-06 +* threads: programmatically hide individual variables in palette + ### 2021-10-05 * threads, store: added infrastructure for hiding individual variables in palette diff --git a/snap.html b/snap.html index 38daa144..8900596d 100755 --- a/snap.html +++ b/snap.html @@ -17,7 +17,7 @@ - + diff --git a/src/threads.js b/src/threads.js index 2a973eea..5b19735a 100644 --- a/src/threads.js +++ b/src/threads.js @@ -64,7 +64,7 @@ SnapExtensions, AlignmentMorph, TextMorph, Cloud*/ /*jshint esversion: 6*/ -modules.threads = '2021-October-05'; +modules.threads = '2021-October-06'; var ThreadManager; var Process; @@ -1839,7 +1839,17 @@ Process.prototype.doRemoveTemporaries = function () { } }; -// Process hiding and showing primitives primitives :-) +// Process hiding and showing blocks in the palette + +Process.prototype.doChangeBlockVisibility = function (aBlock, hideIt) { + if (aBlock.isCustomBlock) { + this.doChangeCustomBlockVisibility(aBlock, hideIt); + } else if (aBlock.spec === 'reportGetVar') { + this.doChangeVarBlockVisibility(aBlock.blockSpec, hideIt); + } else { + this.doChangePrimitiveVisibility(aBlock, hideIt); + } +}; Process.prototype.doChangePrimitiveVisibility = function (aBlock, hideIt) { var ide = this.homeContext.receiver.parentThatIsA(IDE_Morph), @@ -1864,9 +1874,8 @@ Process.prototype.doChangePrimitiveVisibility = function (aBlock, hideIt) { if (cat === 'lists') {cat = 'variables'; } ide.flushBlocksCache(cat); ide.refreshPalette(); -}; -// Process hiding and showing custom blocks primitives +}; Process.prototype.doChangeCustomBlockVisibility = function (aBlock, hideIt) { var ide = this.homeContext.receiver.parentThatIsA(IDE_Morph), @@ -1880,6 +1889,14 @@ Process.prototype.doChangeCustomBlockVisibility = function (aBlock, hideIt) { ide.refreshPalette(); }; +Process.prototype.doChangeVarBlockVisibility = function (name, hideIt) { + var rcvr = this.blockReceiver(), + ide = rcvr.parentThatIsA(IDE_Morph); + rcvr.variables.find(name).vars[name].isHidden = !!hideIt; + ide.flushBlocksCache('variables'); + ide.refreshPalette(); +}; + // Process sprite inheritance primitives Process.prototype.doDeleteAttr = function (attrName) {