mirror of
https://github.com/google/blockly.git
synced 2026-01-09 10:00:09 +01:00
Fix renaming
This commit is contained in:
@@ -724,6 +724,24 @@ Blockly.Block.prototype.renameVar = function(oldName, newName) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Notification that a variable is renaming.
|
||||
* If the name matches one of this block's variables, rename it.
|
||||
* @param {string} oldId ID of variable to rename.
|
||||
* @param {string} newId ID of new variable. May be the same as oldId, but with
|
||||
* an updated name.
|
||||
*/
|
||||
Blockly.Block.prototype.renameVarById = function(oldId, newId) {
|
||||
for (var i = 0, input; input = this.inputList[i]; i++) {
|
||||
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
||||
if (field instanceof Blockly.FieldVariable &&
|
||||
oldId == field.getValue()) {
|
||||
field.setValue(newId);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the language-neutral value from the field of a block.
|
||||
* @param {string} name The name of the field.
|
||||
|
||||
Reference in New Issue
Block a user