1234567891011121314151617181920212223242526272829303132333435363738394041 |
- Blockly.Blocks['set_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);
- this.itemCount_ = 3;
- this.updateShape_();
- this.setOutput(true, 'Set');
- 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 set of")
- };
|