123456789101112131415161718192021222324252627282930313233343536373839404142 |
- Blockly.Blocks['tuple_create'] = {
- /**
- * Block for creating a list with any number of elements of any type.
- * @this Blockly.Block
- */
- init: function() {
- this.setHelpUrl(Blockly.Msg.LISTS_CREATE_WITH_HELPURL);
- this.setColour(Blockly.Blocks.lists.HUE+10);
- this.itemCount_ = 3;
- this.updateShape_();
- this.setOutput(true, 'Tuple');
- this.setInputsInline(true);
- this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_TOOLTIP);
- },
- /**
- * Create XML to represent list inputs.
- * @return {!Element} XML storage element.
- * @this Blockly.Block
- */
- mutationToDom: function() {
- var container = document.createElement('mutation');
- container.setAttribute('items', this.itemCount_);
- return container;
- },
- /**
- * Parse XML to restore the list inputs.
- * @param {!Element} xmlElement XML storage element.
- * @this Blockly.Block
- */
- domToMutation: function(xmlElement) {
- this.itemCount_ = parseInt(xmlElement.getAttribute('items'), 10);
- this.updateShape_();
- },
- /**
- * Modify this block to have the correct number of inputs.
- * @private
- * @this Blockly.Block
- */
- updateShape_: PLUS_MINUS_updateShape('ADD', "create tuple of")
- };
|