summaryrefslogtreecommitdiff
path: root/blocks.js
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-04-04 20:08:28 +0200
committerjmoenig <jens@moenig.org>2013-04-04 20:08:28 +0200
commit80ee7b8c5361e468aef4e2398ecdf2b87059e254 (patch)
tree5f159affffca29287c4a5191413054fa1580518c /blocks.js
parent8f249e63bb07f978322fc1fa68b44ca70062dda5 (diff)
downloadsnap-80ee7b8c5361e468aef4e2398ecdf2b87059e254.tar.gz
snap-80ee7b8c5361e468aef4e2398ecdf2b87059e254.zip
Display Custom Block Comments as Help
Selecting "Help" for a custom block now pops up the comment attached to its definition's prototype hat, if any
Diffstat (limited to 'blocks.js')
-rw-r--r--blocks.js27
1 files changed, 24 insertions, 3 deletions
diff --git a/blocks.js b/blocks.js
index 6805bca..fc8d90e 100644
--- a/blocks.js
+++ b/blocks.js
@@ -153,7 +153,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.blocks = '2013-April-03';
+modules.blocks = '2013-April-04';
var SyntaxElementMorph;
var BlockMorph;
@@ -2029,7 +2029,10 @@ BlockMorph.prototype.showHelp = function () {
var myself = this,
pic = new Image(),
help,
- spec = this.selector === 'evaluateCustomBlock' ?
+ comment,
+ block,
+ isCustomBlock = this.selector === 'evaluateCustomBlock',
+ spec = isCustomBlock ?
this.definition.helpSpec() : this.selector,
ctx;
@@ -2044,7 +2047,25 @@ BlockMorph.prototype.showHelp = function () {
help
);
};
- pic.src = 'help/' + spec + '.png';
+
+ if (isCustomBlock && this.definition.comment) {
+ block = this.fullCopy();
+ block.addShadow();
+ comment = this.definition.comment.fullCopy();
+ comment.contents.parse();
+ help = '';
+ comment.contents.lines.forEach(function (line) {
+ help = help + '\n' + line;
+ });
+ new DialogBoxMorph().inform(
+ 'Help',
+ help.substr(1),
+ myself.world(),
+ block.fullImage()
+ );
+ } else {
+ pic.src = 'help/' + spec + '.png';
+ }
};
// BlockMorph drawing