From de1483fb55db2ef788ae787c67a245f027cb212d Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 28 Oct 2021 11:16:10 +0200 Subject: [PATCH] introduced default values for expandable slot specs --- HISTORY.md | 1 + snap.html | 4 ++-- src/blocks.js | 17 +++++++++++++++-- src/objects.js | 8 +++----- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 243d4d50..c08116f9 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -48,6 +48,7 @@ * Chinese, thanks, Simon! ### 2021-10-28 +* introduced default values for expandable slot specs * updated German translation * migrated Basque and Swedish translations to new BROADCAST block specs diff --git a/snap.html b/snap.html index 9f1cf483..93a9674a 100755 --- a/snap.html +++ b/snap.html @@ -16,9 +16,9 @@ - + - + diff --git a/src/blocks.js b/src/blocks.js index 15c9ecee..d59b046f 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -160,7 +160,7 @@ CustomCommandBlockMorph, ToggleButtonMorph, DialMorph, SnapExtensions*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2021-October-22'; +modules.blocks = '2021-October-28'; var SyntaxElementMorph; var BlockMorph; @@ -312,6 +312,7 @@ SyntaxElementMorph.prototype.labelParts = { tags: 'numeric read-only unevaluated landscape static' menu: dictionary or selector react: selector + value: string, number or Array for localized strings / constants */ '%s': { type: 'input' @@ -519,7 +520,8 @@ SyntaxElementMorph.prototype.labelParts = { '%rcv': { type: 'input', tags: 'read-only', - menu: 'receiversMenu' + menu: 'receiversMenu', + value: ['all'] }, '%spr': { type: 'input', @@ -1703,6 +1705,17 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { throw new Error('unknown label part type: "' + info.type + '"'); } + // apply the default value + // ----------------------- + // only for input slots and Boolean inputs, + // and only for rare exceptions where we cannot + // specify the default values in the block specs, + // e.g. for expandable "reeiver" slots in "broadcast" + + if (!isNil(info.value)) { + part.setContents(info.value); + } + // apply the tags // --------------- // input: numeric, read-only, unevaluated, landscape, static diff --git a/src/objects.js b/src/objects.js index e5908176..f49ea5c2 100644 --- a/src/objects.js +++ b/src/objects.js @@ -87,7 +87,7 @@ BlockVisibilityDialogMorph*/ /*jshint esversion: 6*/ -modules.objects = '2021-October-26'; +modules.objects = '2021-October-28'; var SpriteMorph; var StageMorph; @@ -762,14 +762,12 @@ SpriteMorph.prototype.initBlocks = function () { doBroadcast: { type: 'command', category: 'control', - spec: 'broadcast %msg %receive', - defaults: [null, ['all']] + spec: 'broadcast %msg %receive' }, doBroadcastAndWait: { type: 'command', category: 'control', - spec: 'broadcast %msg %receive and wait', - defaults: [null, ['all']] + spec: 'broadcast %msg %receive and wait' }, doWait: { type: 'command',