added "all" option to the receiver-dropdown of the SEND block

snap7
jmoenig 2021-10-21 14:10:59 +02:00
rodzic d420fc3f8e
commit 4c1f8725e4
4 zmienionych plików z 28 dodań i 3 usunięć

Wyświetl plik

@ -46,6 +46,7 @@
* threads, objects: make "when I receive 'any message'" hat scripts threadsafe (uninterruptable by other messages)
* threads: enabled sending atomic lists to other scenes
* threads: took out broadcasting a 2-item list to mean a message directed to a particular sprite
* blocks, objects, threads: added "all" option to the receiver-dropdown of the SEND block
### 2021-10-20
* blocks: enable sending green-flag events when switching scenes

Wyświetl plik

@ -160,7 +160,7 @@ CustomCommandBlockMorph, ToggleButtonMorph, DialMorph, SnapExtensions*/
// Global stuff ////////////////////////////////////////////////////////
modules.blocks = '2021-October-20';
modules.blocks = '2021-October-21';
var SyntaxElementMorph;
var BlockMorph;
@ -515,6 +515,11 @@ SyntaxElementMorph.prototype.labelParts = {
tags: 'read-only',
menu: 'locationMenu'
},
'%rcv': {
type: 'input',
tags: 'read-only',
menu: 'receiversMenu'
},
'%spr': {
type: 'input',
tags: 'read-only',
@ -9529,6 +9534,22 @@ InputSlotMorph.prototype.objectsMenu = function (searching, includeMyself) {
return dict;
};
InputSlotMorph.prototype.receiversMenu = function (searching) {
var rcvr = this.parentThatIsA(BlockMorph).scriptTarget(),
stage = rcvr.parentThatIsA(StageMorph),
dict = {all: ['all']};
if (searching) {return dict; }
dict['~'] = null;
dict[stage.name] = stage.name;
stage.children.forEach(morph => {
if (morph instanceof SpriteMorph && !morph.isTemporary) {
dict[morph.name] = morph.name;
}
});
return dict;
};
InputSlotMorph.prototype.typesMenu = function () {
var dict = {
number : ['number'],

Wyświetl plik

@ -770,7 +770,8 @@ SpriteMorph.prototype.initBlocks = function () {
doSend: {
type: 'command',
category: 'control',
spec: 'send %msg to %spr'
spec: 'send %msg to %rcv',
defaults: [null, ['all']]
},
doWait: {
type: 'command',

Wyświetl plik

@ -3753,7 +3753,9 @@ Process.prototype.doSend = function (message, target) {
// determine the receivers
thisObj = this.blockReceiver();
if (isSnapObject(target)) {
if (target instanceof Array && target[0] === 'all') {
rcvrs = stage.children.concat(stage);
} else if (isSnapObject(target)) {
rcvrs = [target];
} else if (isString(target)) {
// assume the string to be the name of a sprite or the stage