function customContextMenu(options) {
    var name;

    if (!this.isInFlyout) {
      // Getter blocks have the option to create a setter block, and vice versa.
      var opposite_type, contextMenuMsg;

      if (this.type === 'ast_Name') {
        opposite_type = 'ast_Assign';
        contextMenuMsg = Blockly.Msg['VARIABLES_GET_CREATE_SET'];
      } else {
        opposite_type = 'ast_Name';
        contextMenuMsg = Blockly.Msg['VARIABLES_SET_CREATE_GET'];
      }

      var option = {
        enabled: this.workspace.remainingCapacity() > 0
      };
      name = this.getField('VAR').getText();
      option.text = contextMenuMsg.replace('%1', name);
      var xmlField = document.createElement('field');
      xmlField.setAttribute('name', 'VAR');
      xmlField.appendChild(document.createTextNode(name));
      var xmlBlock = document.createElement('block');
      xmlBlock.setAttribute('type', opposite_type);
      xmlBlock.appendChild(xmlField);
      option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);
      options.push(option); // Getter blocks have the option to rename or delete that variable.
    } else {
      if (this.type === 'ast_Name' || this.type === 'variables_get_reporter') {
        var renameOption = {
          text: Blockly.Msg.RENAME_VARIABLE,
          enabled: true,
          callback: Blockly.Constants.Variables.RENAME_OPTION_CALLBACK_FACTORY(this)
        };
        name = this.getField('VAR').getText();
        var deleteOption = {
          text: Blockly.Msg.DELETE_VARIABLE.replace('%1', name),
          enabled: true,
          callback: Blockly.Constants.Variables.DELETE_OPTION_CALLBACK_FACTORY(this)
        };
        options.unshift(renameOption);
        options.unshift(deleteOption);
      }
    }
  }
/**
   * 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
   */
Add menu option to create getter/setter block for this setter/getter.
@param {!Array} options List of menu options to add to.
Add menu option to create getter / setter block for this setter / getter . @param { !Array } options List of menu options to add to .
function customContextMenu(options) {
    var name;
    if (!this.isInFlyout) {
      var opposite_type, contextMenuMsg;
      if (this.type === 'ast_Name') {
        opposite_type = 'ast_Assign';
        contextMenuMsg = Blockly.Msg['VARIABLES_GET_CREATE_SET'];
      } else {
        opposite_type = 'ast_Name';
        contextMenuMsg = Blockly.Msg['VARIABLES_SET_CREATE_GET'];
      }
      var option = {
        enabled: this.workspace.remainingCapacity() > 0
      };
      name = this.getField('VAR').getText();
      option.text = contextMenuMsg.replace('%1', name);
      var xmlField = document.createElement('field');
      xmlField.setAttribute('name', 'VAR');
      xmlField.appendChild(document.createTextNode(name));
      var xmlBlock = document.createElement('block');
      xmlBlock.setAttribute('type', opposite_type);
      xmlBlock.appendChild(xmlField);
      option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);
      options.push(option); 
    } else {
      if (this.type === 'ast_Name' || this.type === 'variables_get_reporter') {
        var renameOption = {
          text: Blockly.Msg.RENAME_VARIABLE,
          enabled: true,
          callback: Blockly.Constants.Variables.RENAME_OPTION_CALLBACK_FACTORY(this)
        };
        name = this.getField('VAR').getText();
        var deleteOption = {
          text: Blockly.Msg.DELETE_VARIABLE.replace('%1', name),
          enabled: true,
          callback: Blockly.Constants.Variables.DELETE_OPTION_CALLBACK_FACTORY(this)
        };
        options.unshift(renameOption);
        options.unshift(deleteOption);
      }
    }
  }
function customContextMenu ( options ) { var name ; if ( ! this . isInFlyout ) { var opposite_type , contextMenuMsg ; if ( this . type === 'ast_Name' ) { opposite_type = 'ast_Assign' ; contextMenuMsg = Blockly . Msg [ 'VARIABLES_GET_CREATE_SET' ] ; } else { opposite_type = 'ast_Name' ; contextMenuMsg = Blockly . Msg [ 'VARIABLES_SET_CREATE_GET' ] ; } var option = { enabled : this . workspace . remainingCapacity ( ) > 0 } ; name = this . getField ( 'VAR' ) . getText ( ) ; option . text = contextMenuMsg . replace ( '%1' , name ) ; var xmlField = document . createElement ( 'field' ) ; xmlField . setAttribute ( 'name' , 'VAR' ) ; xmlField . appendChild ( document . createTextNode ( name ) ) ; var xmlBlock = document . createElement ( 'block' ) ; xmlBlock . setAttribute ( 'type' , opposite_type ) ; xmlBlock . appendChild ( xmlField ) ; option . callback = Blockly . ContextMenu . callbackFactory ( this , xmlBlock ) ; options . push ( option ) ; } else { if ( this . type === 'ast_Name' || this . type === 'variables_get_reporter' ) { var renameOption = { text : Blockly . Msg . RENAME_VARIABLE , enabled : true , callback : Blockly . Constants . Variables . RENAME_OPTION_CALLBACK_FACTORY ( this ) } ; name = this . getField ( 'VAR' ) . getText ( ) ; var deleteOption = { text : Blockly . Msg . DELETE_VARIABLE . replace ( '%1' , name ) , enabled : true , callback : Blockly . Constants . Variables . DELETE_OPTION_CALLBACK_FACTORY ( this ) } ; options . unshift ( renameOption ) ; options . unshift ( deleteOption ) ; } } }
Add menu option to create getter/setter block for this setter/getter.
Add menu option to create getter / setter block for this setter / getter .
// Getter blocks have the option to create a setter block, and vice versa. // Getter blocks have the option to rename or delete that variable.