components/blockly-src/blocks/procedures.js
function(options) {
    // Add option to create caller.
    var option = {enabled: true};
    var name = this.getFieldValue('NAME');
    option.text = Blockly.Msg.PROCEDURES_CREATE_DO.replace('%1', name);
    var xmlMutation = goog.dom.createDom('mutation');
    xmlMutation.setAttribute('name', name);
    for (var i = 0; i < this.arguments_.length; i++) {
      var xmlArg = goog.dom.createDom('arg');
      xmlArg.setAttribute('name', this.arguments_[i]);
      xmlMutation.appendChild(xmlArg);
    }
    var xmlBlock = goog.dom.createDom('block', null, xmlMutation);
    xmlBlock.setAttribute('type', this.callType_);
    option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);
    options.push(option);

    // Add options to create getters for each parameter.
    if (!this.isCollapsed()) {
      for (var i = 0; i < this.arguments_.length; i++) {
        var option = {enabled: true};
        var name = this.arguments_[i];
        option.text = Blockly.Msg.VARIABLES_SET_CREATE_GET.replace('%1', name);
        var xmlField = goog.dom.createDom('field', null, name);
        xmlField.setAttribute('name', 'VAR');
        var xmlBlock = goog.dom.createDom('block', null, xmlField);
        xmlBlock.setAttribute('type', 'variables_get');
        option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);
        options.push(option);
      }
    }
  }
function(options) {
    // Add option to create caller.
    var option = {enabled: true};
    var name = this.getFieldValue('NAME');
    option.text = Blockly.Msg.PROCEDURES_CREATE_DO.replace('%1', name);
    var xmlMutation = goog.dom.createDom('mutation');
    xmlMutation.setAttribute('name', name);
    for (var i = 0; i < this.arguments_.length; i++) {
      var xmlArg = goog.dom.createDom('arg');
      xmlArg.setAttribute('name', this.arguments_[i]);
      xmlMutation.appendChild(xmlArg);
    }
    var xmlBlock = goog.dom.createDom('block', null, xmlMutation);
    xmlBlock.setAttribute('type', this.callType_);
    option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);
    options.push(option);

    // Add options to create getters for each parameter.
    if (!this.isCollapsed()) {
      for (var i = 0; i < this.arguments_.length; i++) {
        var option = {enabled: true};
        var name = this.arguments_[i];
        option.text = Blockly.Msg.VARIABLES_SET_CREATE_GET.replace('%1', name);
        var xmlField = goog.dom.createDom('field', null, name);
        xmlField.setAttribute('name', 'VAR');
        var xmlBlock = goog.dom.createDom('block', null, xmlField);
        xmlBlock.setAttribute('type', 'variables_get');
        option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);
        options.push(option);
      }
    }
  }
function ( options ) { // Add option to create caller. var option = { enabled : true } ; var name = this . getFieldValue ( 'NAME' ) ; option . text = Blockly . Msg . PROCEDURES_CREATE_DO . replace ( '%1' , name ) ; var xmlMutation = goog . dom . createDom ( 'mutation' ) ; xmlMutation . setAttribute ( 'name' , name ) ; for ( var i = 0 ; i < this . arguments_ . length ; i ++ ) { var xmlArg = goog . dom . createDom ( 'arg' ) ; xmlArg . setAttribute ( 'name' , this . arguments_ [ i ] ) ; xmlMutation . appendChild ( xmlArg ) ; } var xmlBlock = goog . dom . createDom ( 'block' , null , xmlMutation ) ; xmlBlock . setAttribute ( 'type' , this . callType_ ) ; option . callback = Blockly . ContextMenu . callbackFactory ( this , xmlBlock ) ; options . push ( option ) ; // Add options to create getters for each parameter. if ( ! this . isCollapsed ( ) ) { for ( var i = 0 ; i < this . arguments_ . length ; i ++ ) { var option = { enabled : true } ; var name = this . arguments_ [ i ] ; option . text = Blockly . Msg . VARIABLES_SET_CREATE_GET . replace ( '%1' , name ) ; var xmlField = goog . dom . createDom ( 'field' , null , name ) ; xmlField . setAttribute ( 'name' , 'VAR' ) ; var xmlBlock = goog . dom . createDom ( 'block' , null , xmlField ) ; xmlBlock . setAttribute ( 'type' , 'variables_get' ) ; option . callback = Blockly . ContextMenu . callbackFactory ( this , xmlBlock ) ; options . push ( option ) ; } } }
Add custom menu options to this block's context menu.
@param {!Array} options List of menu options to add to.
@this Blockly.Block
Add custom menu options to this block s context menu .