blocks_vertical/data.js
function(options) {
    var fieldName = 'LIST';
    if (this.isCollapsed()) {
      return;
    }
    var currentVarName = this.getField(fieldName).text_;
    if (!this.isInFlyout) {
      var variablesList = this.workspace.getVariablesOfType('list');
      for (var i = 0; i < variablesList.length; i++) {
        var varName = variablesList[i].name;
        if (varName == currentVarName) continue;

        var option = {enabled: true};
        option.text = varName;

        option.callback =
            Blockly.Constants.Data.VARIABLE_OPTION_CALLBACK_FACTORY(this,
                variablesList[i].getId(), fieldName);
        options.push(option);
      }
    } else {
      var renameOption = {
        text: Blockly.Msg.RENAME_LIST,
        enabled: true,
        callback: Blockly.Constants.Data.RENAME_OPTION_CALLBACK_FACTORY(this,
            fieldName)
      };
      var deleteOption = {
        text: Blockly.Msg.DELETE_LIST.replace('%1', currentVarName),
        enabled: true,
        callback: Blockly.Constants.Data.DELETE_OPTION_CALLBACK_FACTORY(this,
            fieldName)
      };
      options.push(renameOption);
      options.push(deleteOption);
    }
  }
function(options) {
    var fieldName = 'LIST';
    if (this.isCollapsed()) {
      return;
    }
    var currentVarName = this.getField(fieldName).text_;
    if (!this.isInFlyout) {
      var variablesList = this.workspace.getVariablesOfType('list');
      for (var i = 0; i < variablesList.length; i++) {
        var varName = variablesList[i].name;
        if (varName == currentVarName) continue;

        var option = {enabled: true};
        option.text = varName;

        option.callback =
            Blockly.Constants.Data.VARIABLE_OPTION_CALLBACK_FACTORY(this,
                variablesList[i].getId(), fieldName);
        options.push(option);
      }
    } else {
      var renameOption = {
        text: Blockly.Msg.RENAME_LIST,
        enabled: true,
        callback: Blockly.Constants.Data.RENAME_OPTION_CALLBACK_FACTORY(this,
            fieldName)
      };
      var deleteOption = {
        text: Blockly.Msg.DELETE_LIST.replace('%1', currentVarName),
        enabled: true,
        callback: Blockly.Constants.Data.DELETE_OPTION_CALLBACK_FACTORY(this,
            fieldName)
      };
      options.push(renameOption);
      options.push(deleteOption);
    }
  }
function ( options ) { var fieldName = 'LIST' ; if ( this . isCollapsed ( ) ) { return ; } var currentVarName = this . getField ( fieldName ) . text_ ; if ( ! this . isInFlyout ) { var variablesList = this . workspace . getVariablesOfType ( 'list' ) ; for ( var i = 0 ; i < variablesList . length ; i ++ ) { var varName = variablesList [ i ] . name ; if ( varName == currentVarName ) continue ; var option = { enabled : true } ; option . text = varName ; option . callback = Blockly . Constants . Data . VARIABLE_OPTION_CALLBACK_FACTORY ( this , variablesList [ i ] . getId ( ) , fieldName ) ; options . push ( option ) ; } } else { var renameOption = { text : Blockly . Msg . RENAME_LIST , enabled : true , callback : Blockly . Constants . Data . RENAME_OPTION_CALLBACK_FACTORY ( this , fieldName ) } ; var deleteOption = { text : Blockly . Msg . DELETE_LIST . replace ( '%1' , currentVarName ) , enabled : true , callback : Blockly . Constants . Data . DELETE_OPTION_CALLBACK_FACTORY ( this , fieldName ) } ; options . push ( renameOption ) ; options . push ( deleteOption ) ; } }
Add context menu option to change the selected list.
@param {!Array} options List of menu options to add to.
@this Blockly.Block
Add context menu option to change the selected list .