From 7478efdca9835d6860593eabe7d968f90ca03d22 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 6 Feb 2019 08:44:07 +0100 Subject: [PATCH] refactored custom block input slot options / menus avoid errors in case users edit menus in ways that are not supported --- HISTORY.md | 3 +++ snap.html | 4 ++-- src/blocks.js | 6 +++++- src/byob.js | 19 ++++++++++++++++--- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index ab90ec5c..615bbe16 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -36,6 +36,9 @@ * Greek, thanks, Alexandros! * German +### 2019-02-06 +* Blocks, BYOB: refactored custom block input options and drop-down menus + ### 2019-02-05 * BYOB: radio button symbols for special slot / drop-down menu options diff --git a/snap.html b/snap.html index 33bff7d8..4f308e9c 100755 --- a/snap.html +++ b/snap.html @@ -6,13 +6,13 @@ - + - + diff --git a/src/blocks.js b/src/blocks.js index eec738ca..4d3290ed 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -148,7 +148,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2019-February-04'; +modules.blocks = '2019-February-06'; var SyntaxElementMorph; var BlockMorph; @@ -8917,6 +8917,10 @@ InputSlotMorph.prototype.pianoKeyboardMenu = function () { menu.selectKey(+this.evaluate()); }; +InputSlotMorph.prototype.directionDialMenu = function () { + return {'§_dir': null}; +}; + InputSlotMorph.prototype.setChoices = function (dict, readonly) { // externally specify choices and read-only status, // used for custom blocks diff --git a/src/byob.js b/src/byob.js index ed0a6203..897a412e 100644 --- a/src/byob.js +++ b/src/byob.js @@ -108,7 +108,7 @@ BooleanSlotMorph, XML_Serializer, SnapTranslator*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2019-February-05'; +modules.byob = '2019-February-06'; // Declarations @@ -320,9 +320,20 @@ CustomBlockDefinition.prototype.dropDownMenuOf = function (inputName) { var fname; if (this.declarations.has(inputName) && this.declarations.get(inputName)[2]) { - if ( (this.declarations.get(inputName)[2].indexOf('§_') === 0)) { + if ((this.declarations.get(inputName)[2].indexOf('§_') === 0)) { fname = this.declarations.get(inputName)[2].slice(2); - if (fname !== 'dir') { + if (contains( + [ + 'messagesReceivedMenu', + 'objectsMenu', + 'costumesMenu', + 'soundsMenu', + 'getVarNamesDict', + 'pianoKeyboardMenu', + 'directionDialMenu' + ], + fname + )) { return fname; } } @@ -3713,6 +3724,8 @@ InputSlotDialogMorph.prototype.specialOptionsMenu = function () { ); } + // +++ add another radio button for "options" + addSpecialOptions('(none)', ''); addSpecialOptions('messages', '§_messagesReceivedMenu'); addSpecialOptions('objects', '§_objectsMenu'); // addSpecialOptions('data types', '§_typesMenu');