mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
Provide default getVars and renameVar functions. Issue 265.
This commit is contained in:
@@ -168,26 +168,6 @@ Blockly.Blocks['controls_for'] = {
|
||||
thisBlock.getFieldValue('VAR'));
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Return all variables referenced by this block.
|
||||
* @return {!Array.<string>} List of variable names.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
getVars: function() {
|
||||
return [this.getFieldValue('VAR')];
|
||||
},
|
||||
/**
|
||||
* Notification that a variable is renaming.
|
||||
* If the name matches one of this block's variables, rename it.
|
||||
* @param {string} oldName Previous name of variable.
|
||||
* @param {string} newName Renamed variable.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
renameVar: function(oldName, newName) {
|
||||
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
|
||||
this.setFieldValue(newName, 'VAR');
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Add menu option to create getter block for loop variable.
|
||||
* @param {!Array} options List of menu options to add to.
|
||||
@@ -242,26 +222,6 @@ Blockly.Blocks['controls_forEach'] = {
|
||||
thisBlock.getFieldValue('VAR'));
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Return all variables referenced by this block.
|
||||
* @return {!Array.<string>} List of variable names.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
getVars: function() {
|
||||
return [this.getFieldValue('VAR')];
|
||||
},
|
||||
/**
|
||||
* Notification that a variable is renaming.
|
||||
* If the name matches one of this block's variables, rename it.
|
||||
* @param {string} oldName Previous name of variable.
|
||||
* @param {string} newName Renamed variable.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
renameVar: function(oldName, newName) {
|
||||
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
|
||||
this.setFieldValue(newName, 'VAR');
|
||||
}
|
||||
},
|
||||
customContextMenu: Blockly.Blocks['controls_for'].customContextMenu
|
||||
};
|
||||
|
||||
|
||||
@@ -288,26 +288,6 @@ Blockly.Blocks['math_change'] = {
|
||||
return Blockly.Msg.MATH_CHANGE_TOOLTIP.replace('%1',
|
||||
thisBlock.getFieldValue('VAR'));
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Return all variables referenced by this block.
|
||||
* @return {!Array.<string>} List of variable names.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
getVars: function() {
|
||||
return [this.getFieldValue('VAR')];
|
||||
},
|
||||
/**
|
||||
* Notification that a variable is renaming.
|
||||
* If the name matches one of this block's variables, rename it.
|
||||
* @param {string} oldName Previous name of variable.
|
||||
* @param {string} newName Renamed variable.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
renameVar: function(oldName, newName) {
|
||||
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
|
||||
this.setFieldValue(newName, 'VAR');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -247,26 +247,6 @@ Blockly.Blocks['text_append'] = {
|
||||
return Blockly.Msg.TEXT_APPEND_TOOLTIP.replace('%1',
|
||||
thisBlock.getFieldValue('VAR'));
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Return all variables referenced by this block.
|
||||
* @return {!Array.<string>} List of variable names.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
getVars: function() {
|
||||
return [this.getFieldValue('VAR')];
|
||||
},
|
||||
/**
|
||||
* Notification that a variable is renaming.
|
||||
* If the name matches one of this block's variables, rename it.
|
||||
* @param {string} oldName Previous name of variable.
|
||||
* @param {string} newName Renamed variable.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
renameVar: function(oldName, newName) {
|
||||
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
|
||||
this.setFieldValue(newName, 'VAR');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -49,26 +49,6 @@ Blockly.Blocks['variables_get'] = {
|
||||
this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP);
|
||||
this.contextMenuMsg_ = Blockly.Msg.VARIABLES_GET_CREATE_SET;
|
||||
},
|
||||
/**
|
||||
* Return all variables referenced by this block.
|
||||
* @return {!Array.<string>} List of variable names.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
getVars: function() {
|
||||
return [this.getFieldValue('VAR')];
|
||||
},
|
||||
/**
|
||||
* Notification that a variable is renaming.
|
||||
* If the name matches one of this block's variables, rename it.
|
||||
* @param {string} oldName Previous name of variable.
|
||||
* @param {string} newName Renamed variable.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
renameVar: function(oldName, newName) {
|
||||
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
|
||||
this.setFieldValue(newName, 'VAR');
|
||||
}
|
||||
},
|
||||
contextMenuType_: 'variables_set',
|
||||
/**
|
||||
* Add menu option to create getter/setter block for this setter/getter.
|
||||
@@ -115,26 +95,6 @@ Blockly.Blocks['variables_set'] = {
|
||||
});
|
||||
this.contextMenuMsg_ = Blockly.Msg.VARIABLES_SET_CREATE_GET;
|
||||
},
|
||||
/**
|
||||
* Return all variables referenced by this block.
|
||||
* @return {!Array.<string>} List of variable names.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
getVars: function() {
|
||||
return [this.getFieldValue('VAR')];
|
||||
},
|
||||
/**
|
||||
* Notification that a variable is renaming.
|
||||
* If the name matches one of this block's variables, rename it.
|
||||
* @param {string} oldName Previous name of variable.
|
||||
* @param {string} newName Renamed variable.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
renameVar: function(oldName, newName) {
|
||||
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
|
||||
this.setFieldValue(newName, 'VAR');
|
||||
}
|
||||
},
|
||||
contextMenuType_: 'variables_get',
|
||||
customContextMenu: Blockly.Blocks['variables_get'].customContextMenu
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user