mirror of
https://github.com/google/blockly.git
synced 2026-01-08 09:30:06 +01:00
Update to latest version.
This commit is contained in:
@@ -30,7 +30,10 @@ goog.require('Blockly.Blocks');
|
||||
|
||||
|
||||
Blockly.Blocks['variables_get'] = {
|
||||
// Variable getter.
|
||||
/**
|
||||
* Block for variable getter.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL);
|
||||
this.setColour(330);
|
||||
@@ -44,14 +47,31 @@ Blockly.Blocks['variables_get'] = {
|
||||
this.contextMenuMsg_ = Blockly.Msg.VARIABLES_GET_CREATE_SET;
|
||||
this.contextMenuType_ = 'variables_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');
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Add menu option to create getter/setter block for this setter/getter.
|
||||
* @param {!Array} options List of menu options to add to.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
customContextMenu: function(options) {
|
||||
var option = {enabled: true};
|
||||
var name = this.getFieldValue('VAR');
|
||||
@@ -66,7 +86,10 @@ Blockly.Blocks['variables_get'] = {
|
||||
};
|
||||
|
||||
Blockly.Blocks['variables_set'] = {
|
||||
// Variable setter.
|
||||
/**
|
||||
* Block for variable setter.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function() {
|
||||
this.setHelpUrl(Blockly.Msg.VARIABLES_SET_HELPURL);
|
||||
this.setColour(330);
|
||||
@@ -83,9 +106,21 @@ Blockly.Blocks['variables_set'] = {
|
||||
this.contextMenuMsg_ = Blockly.Msg.VARIABLES_SET_CREATE_GET;
|
||||
this.contextMenuType_ = 'variables_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');
|
||||
|
||||
Reference in New Issue
Block a user