mirror of
https://github.com/google/blockly.git
synced 2026-01-09 10:00:09 +01:00
Merge pull request #2618 from alschmiedt/dynamic_variable_error
Fixes bug with using dynamic variable in toolbox
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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.<string>} 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] == '') {
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user