How to use the blockly.Blocks function in blockly

To help you get started, we’ve selected a few blockly examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github miguel76 / SparqlBlocks / src / blocks / text.js View on Github external
}
    // Rebuild block.
    if (this.itemCount_ == 0) {
      this.appendDummyInput('EMPTY')
          .appendField(this.newQuote_(true))
          .appendField(this.newQuote_(false));
    } else {
      for (var i = 0; i < this.itemCount_; i++) {
        var input = this.appendValueInput('ADD' + i);
        if (i == 0) {
          input.appendField(Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH);
        }
      }
    }
  },
  newQuote_: Blockly.Blocks['sparql_text'].newQuote_
});

Blocks.block('sparql_text_create_join_container', {
  /**
   * Mutator block for container.
   * @this Blockly.Block
   */
  init: function() {
    this.setColour(HUE);
    this.appendDummyInput()
        .appendField(Blockly.Msg.TEXT_CREATE_JOIN_TITLE_JOIN);
    this.appendStatementInput('STACK');
    this.setTooltip(Blockly.Msg.TEXT_CREATE_JOIN_TOOLTIP);
    this.contextMenu = false;
  }
});
github Paol-imi / blockly-gamepad / src / gamepad.js View on Github external
hastemplate = true;
            }

            // a block must have both or none
            if (hastemplate && !hasStatements) throw new Error('a template block require at least a statement');
            if (!hastemplate && hasStatements) throw new Error('statements setted without the template');

            // load the javascript
            Blockly.JavaScript['' + type] = Gamepad.utils.js(block.method, block.args, block.order, block.template, block.statements);

            // init the block with the json or the javascript
            if ('json' in block) {
                block.json.type = type;
                jsonArray.push(block.json);
            } else if ('javascript' in block) {
                Blockly.Blocks[type] = block.javascript;
            }
        }

        Blockly.defineBlocksWithJsonArray(jsonArray);
    },
    /* wrap standard blocks to generate requests */
github miguel76 / SparqlBlocks / src / blocks / variables.js View on Github external
.appendField("?")
        .appendField(new Blockly.FieldVariable(), "VAR");
    this.setOutput(true, "Var");
    this.setTooltip('');
    // this.appendDummyInput()
    //     .appendField(Blockly.Msg.VARIABLES_GET_TITLE)
    //     .appendField(new Blockly.FieldVariable(
    //     Blockly.Msg.VARIABLES_GET_ITEM), 'VAR')
    //     .appendField(Blockly.Msg.VARIABLES_GET_TAIL);
    // this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP);
    // this.contextMenuMsg_ = Blockly.Msg.VARIABLES_GET_CREATE_SET;
    // this.contextMenuType_ = 'variables_set';
  }
});

Blockly.Blocks.variables_get = Blockly.Blocks.sparql_variable;
Blockly.Blocks.variables_set = null;
github miguel76 / SparqlBlocks / src / blocks / variables.js View on Github external
.appendField(new Blockly.FieldVariable(), "VAR");
    this.setOutput(true, "Var");
    this.setTooltip('');
    // this.appendDummyInput()
    //     .appendField(Blockly.Msg.VARIABLES_GET_TITLE)
    //     .appendField(new Blockly.FieldVariable(
    //     Blockly.Msg.VARIABLES_GET_ITEM), 'VAR')
    //     .appendField(Blockly.Msg.VARIABLES_GET_TAIL);
    // this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP);
    // this.contextMenuMsg_ = Blockly.Msg.VARIABLES_GET_CREATE_SET;
    // this.contextMenuType_ = 'variables_set';
  }
});

Blockly.Blocks.variables_get = Blockly.Blocks.sparql_variable;
Blockly.Blocks.variables_set = null;
github miguel76 / SparqlBlocks / src / core / blocks.js View on Github external
var block_ = function(blockName, block) {
  block.customContextMenu = baseCustomContextMenu_(block.customContextMenu);
  block.init = baseInit_(block.init);
  Blockly.Blocks[blockName] = block;
};