added IDE >> getMessages() to Snap! API

pull/89/head
jmoenig 2019-12-16 08:59:13 +01:00
rodzic ebc456d5f1
commit 9605b6eb73
2 zmienionych plików z 15 dodań i 1 usunięć

Wyświetl plik

@ -18,6 +18,7 @@
### 2019-12-16
* gui, objects: added ability to add general message listeners for "any" message
* gui: added IDE >> getMessages() to Snap! API
### 2019-12-15
* gui, threads: new Snap! API: programmatically broadcast messages and optionally wait from outside Snap!

Wyświetl plik

@ -61,7 +61,7 @@
*/
/*global modules, Morph, SpriteMorph, SyntaxElementMorph, Color, Cloud,
/*global modules, Morph, SpriteMorph, SyntaxElementMorph, Color, Cloud, Map,
ListWatcherMorph, TextMorph, newCanvas, useBlurredShadows, VariableFrame,
StringMorph, Point, MenuMorph, morphicVersion, DialogBoxMorph, normalizeCanvas,
ToggleButtonMorph, contains, ScrollFrameMorph, StageMorph, PushButtonMorph, sb,
@ -6133,6 +6133,19 @@ IDE_Morph.prototype.addMessageListener = function (message, callback) {
}
};
IDE_Morph.prototype.getMessages = function () {
// return an array of all broadcast messages in the current project
var allNames = [],
dict = new Map();
this.sprites.contents.concat(this.stage).forEach(function (sprite) {
allNames = allNames.concat(sprite.allMessageNames());
});
allNames.forEach(function (name) {
dict.set(name);
});
return Array.from(dict.keys());
};
IDE_Morph.prototype.getVarNames = function () {
// return an array of all global variable names
return this.stage.globalVariables().names();