From ce0d2216e1f861aacb27e789ec4763c0523a72f1 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Sat, 21 Nov 2020 11:03:43 +0100 Subject: [PATCH] show the common attributes for sprites in the OF-dropdown by default --- HISTORY.md | 2 ++ snap.html | 2 +- src/blocks.js | 51 +++++++++++++++++++++++++-------------------------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index d70da439..d1ae2f67 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -5,6 +5,7 @@ * **Notable Changes:** * added "loadProjectXML" method to the api * hyperized "atrribute OF sprite" reporter primitive in the sensing category + * show the common attributes for sprites in the OF-dropdown by default * **Documentation Updates:** * API update for "loadProjectXML" @@ -13,6 +14,7 @@ * api: new loadProjectXML() method * updated api documentation * threads: hyperized "atrribute OF sprite" reporter primitive +* blocks: show the common attributes for sprites in the OF-dropdown by default ## 6.3.6 * **Notable Changes:** diff --git a/snap.html b/snap.html index 48744531..09372726 100755 --- a/snap.html +++ b/snap.html @@ -8,7 +8,7 @@ - + diff --git a/src/blocks.js b/src/blocks.js index 31eff976..1b6bd514 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -158,7 +158,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2020-November-17'; +modules.blocks = '2020-November-21'; var SyntaxElementMorph; var BlockMorph; @@ -9417,10 +9417,20 @@ InputSlotMorph.prototype.attributesMenu = function () { morph => morph.name === objName ); } - if (!obj) { - return dict; - } - if (obj instanceof SpriteMorph) { + if (obj instanceof StageMorph) { + dict = { + 'costume #' : ['costume #'], + 'costume name' : ['costume name'], + 'volume' : ['volume'], + 'balance' : ['balance'], + 'width': ['width'], + 'height': ['height'], + 'left' : ['left'], + 'right' : ['right'], + 'top' : ['top'], + 'bottom' : ['bottom'] + }; + } else { // assume a sprite dict = { 'x position' : ['x position'], 'y position' : ['y position'], @@ -9437,30 +9447,19 @@ InputSlotMorph.prototype.attributesMenu = function () { 'volume' : ['volume'], 'balance' : ['balance'] }; - } else { // the stage - dict = { - 'costume #' : ['costume #'], - 'costume name' : ['costume name'], - 'volume' : ['volume'], - 'balance' : ['balance'], - 'width': ['width'], - 'height': ['height'], - 'left' : ['left'], - 'right' : ['right'], - 'top' : ['top'], - 'bottom' : ['bottom'] - }; } - varNames = obj.variables.names(); - if (varNames.length > 0) { - dict['~'] = null; - varNames.forEach(name => - dict[name] = name + if (obj) { + varNames = obj.variables.names(); + if (varNames.length > 0) { + dict['~'] = null; + varNames.forEach(name => + dict[name] = name + ); + } + obj.allBlocks(true).forEach((def, i) => + dict['§_def' + i] = def.blockInstance(true) // include translations ); } - obj.allBlocks(true).forEach((def, i) => - dict['§_def' + i] = def.blockInstance(true) // include translations - ); return dict; };