summaryrefslogtreecommitdiff
path: root/blocks.js
diff options
context:
space:
mode:
Diffstat (limited to 'blocks.js')
-rw-r--r--blocks.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/blocks.js b/blocks.js
index 6f719d9..1d46b6f 100644
--- a/blocks.js
+++ b/blocks.js
@@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/
// Global stuff ////////////////////////////////////////////////////////
-modules.blocks = '2013-October-25';
+modules.blocks = '2013-November-12';
var SyntaxElementMorph;
var BlockMorph;
@@ -517,6 +517,12 @@ SyntaxElementMorph.prototype.revertToDefaultInput = function (arg, noValues) {
if (idx !== -1) {
if (this instanceof BlockMorph) {
deflt = this.labelPart(this.parseSpec(this.blockSpec)[idx]);
+ if (deflt instanceof InputSlotMorph && this.definition) {
+ deflt.choices = this.definition.dropDownMenuOfInputIdx(
+ this.inputs().indexOf(arg)
+ );
+ deflt.fixLayout();
+ }
} else if (this instanceof MultiArgMorph) {
deflt = this.labelPart(this.slotSpec);
} else if (this instanceof ReporterSlotMorph) {
@@ -1889,7 +1895,8 @@ BlockMorph.prototype.parseSpec = function (spec) {
BlockMorph.prototype.setSpec = function (spec) {
var myself = this,
- part;
+ part,
+ inputIdx = -1;
if (!spec) {return; }
this.parts().forEach(function (part) {
@@ -1899,6 +1906,9 @@ BlockMorph.prototype.setSpec = function (spec) {
this.add(this.placeHolder());
}
this.parseSpec(spec).forEach(function (word) {
+ if (word[0] === '%') {
+ inputIdx += 1;
+ }
part = myself.labelPart(word);
myself.add(part);
if (!(part instanceof CommandSlotMorph)) {
@@ -1917,6 +1927,10 @@ BlockMorph.prototype.setSpec = function (spec) {
if (myself.isPrototype) {
myself.add(myself.placeHolder());
}
+ if (part instanceof InputSlotMorph && myself.definition) {
+ part.choices = myself.definition.dropDownMenuOfInputIdx(inputIdx);
+ part.fixLayout(); // needed when de-serializing
+ }
});
this.blockSpec = spec;
this.fixLayout();
@@ -2325,7 +2339,7 @@ BlockMorph.prototype.mapToHeader = function () {
} else {
help = 'Enter code that corresponds to the block\'s definition. ' +
'Choose your own\nformal parameter names (ignoring the ones ' +
- 'shown .';
+ 'shown).';
}
new DialogBoxMorph(
this,