From d50f80662467f66adec32d4bf8f653e9d89f129e Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Thu, 11 Aug 2016 17:31:19 -0700 Subject: [PATCH] Create variables on block creation --- core/field_variable.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/field_variable.js b/core/field_variable.js index d1e7d8894..abaf0a717 100644 --- a/core/field_variable.js +++ b/core/field_variable.js @@ -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()); + } }; /**