mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
Rebase
This commit is contained in:
@@ -98,11 +98,11 @@ Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MI
|
||||
*/
|
||||
customContextMenu: function(options) {
|
||||
// Getter blocks have the option to create a setter block, and vice versa.
|
||||
if(this.isInFlyout){
|
||||
if (this.isInFlyout) {
|
||||
return;
|
||||
}
|
||||
var opposite_type ;
|
||||
var contextMenuMsg ;
|
||||
var opposite_type;
|
||||
var contextMenuMsg;
|
||||
if (this.type == 'variables_get_dynamic') {
|
||||
opposite_type = 'variables_set_dynamic';
|
||||
contextMenuMsg = Blockly.Msg.VARIABLES_GET_CREATE_SET;
|
||||
@@ -124,8 +124,8 @@ Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MI
|
||||
options.push(option);
|
||||
},
|
||||
onchange: function() {
|
||||
var name = this.getFieldValue('VAR');
|
||||
var variableModel = this.workspace.getVariable(name);
|
||||
var id = this.getFieldValue('VAR');
|
||||
var variableModel = this.workspace.getVariableById(id);
|
||||
if (this.type == 'variables_get_dynamic') {
|
||||
this.outputConnection.setCheck(variableModel.type);
|
||||
} else {
|
||||
|
||||
@@ -269,6 +269,9 @@ Blockly.Flyout.prototype.init = function(targetWorkspace) {
|
||||
|
||||
this.workspace_.renameVariableById =
|
||||
this.targetWorkspace_.renameVariableById.bind(this.targetWorkspace_);
|
||||
|
||||
this.workspace_.getVariableTypes =
|
||||
this.targetWorkspace_.getVariableTypes.bind(this.targetWorkspace_);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -247,11 +247,21 @@ Blockly.VariableMap.prototype.getVariablesOfType = function(type) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Return all variable types.
|
||||
* Return all variable types. This list always contains the empty string.
|
||||
* @return {!Array.<string>} List of variable types.
|
||||
*/
|
||||
Blockly.VariableMap.prototype.getVariableTypes = function() {
|
||||
return Object.keys(this.variableMap_);
|
||||
var types = Object.keys(this.variableMap_);
|
||||
var hasEmpty = false;
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
if (types[i] == '') {
|
||||
hasEmpty = true;
|
||||
}
|
||||
}
|
||||
if (!hasEmpty) {
|
||||
types.push('');
|
||||
}
|
||||
return types;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user