diff --git a/blocks/variables_dynamic.js b/blocks/variables_dynamic.js index b0ad6206b..a4f91ced4 100644 --- a/blocks/variables_dynamic.js +++ b/blocks/variables_dynamic.js @@ -150,7 +150,7 @@ Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MI */ onchange: function(_e) { var id = this.getFieldValue('VAR'); - var variableModel = this.workspace.getVariableById(id); + var variableModel = Blockly.Variables.getVariable(this.workspace, id); if (this.type == 'variables_get_dynamic') { this.outputConnection.setCheck(variableModel.type); } else { diff --git a/core/variable_map.js b/core/variable_map.js index a444835ca..f63ec9a65 100644 --- a/core/variable_map.js +++ b/core/variable_map.js @@ -348,12 +348,20 @@ Blockly.VariableMap.prototype.getVariablesOfType = function(type) { }; /** - * Return all variable types. This list always contains the empty string. + * Return all variable and potential variable types. This list always contains + * the empty string. + * @param {?Blockly.Workspace} ws The workspace used to look for potential + * variables. This can be different than the workspace stored on this object + * if the passed in ws is a flyout workspace. * @return {!Array.} List of variable types. * @package */ -Blockly.VariableMap.prototype.getVariableTypes = function() { - var types = Object.keys(this.variableMap_); +Blockly.VariableMap.prototype.getVariableTypes = function(ws) { + var potentialTypes = []; + if (ws && ws.getPotentialVariableMap()) { + potentialTypes = Object.keys(ws.getPotentialVariableMap().variableMap_); + } + var types = Object.keys(this.variableMap_).concat(potentialTypes); var hasEmpty = false; for (var i = 0; i < types.length; i++) { if (types[i] == '') { diff --git a/core/workspace.js b/core/workspace.js index 54b6a260b..5c304bc46 100644 --- a/core/workspace.js +++ b/core/workspace.js @@ -491,7 +491,7 @@ Blockly.Workspace.prototype.getVariablesOfType = function(type) { * @package */ Blockly.Workspace.prototype.getVariableTypes = function() { - return this.variableMap_.getVariableTypes(); + return this.variableMap_.getVariableTypes(this); }; /**