Create variables on block creation

This commit is contained in:
Rachel Fenichel 2016-08-11 17:31:19 -07:00
parent 5e787afe8e
commit d50f806624

View file

@ -65,6 +65,12 @@ Blockly.FieldVariable.prototype.init = function() {
this.sourceBlock_.workspace;
this.setValue(Blockly.Variables.generateUniqueName(workspace));
}
// If the selected variable doesn't exist yet, create it.
// For instance, some blocks in the toolbox have variable dropdowns filled
// in by default.
if (!this.sourceBlock_.isInFlyout) {
this.sourceBlock_.workspace.createVariable(this.getValue());
}
};
/**