Hi
I have a problem with using custom type blocks in the toolbox. Would appreciate some help here.
1) I defined a new block that return a custom type 'font family'. This type is then used for the last argument of the block set_text_attributes (as seen below)
Blockly.Blocks['font_family'] = {
init: function() {
this.appendDummyInput().appendField(new Blockly.FieldDropdown(
[["helvetica", "helvetica"], ["courier", "courier"], ["comic", "comic"]]), "font");
this.setOutput(true, "font family");
}
};
Blockly.Blocks['set_text_attributes'] = {
init: function() {
this.appendDummyInput().appendField("set text settings");
this.appendValueInput("color").setCheck("String").setAlign(Blockly.ALIGN_RIGHT).appendField("text color");
this.appendValueInput("bgcolor").setCheck("String").setAlign(Blockly.ALIGN_RIGHT).appendField("bgcolor");
this.appendValueInput("size").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField("size");
this.appendValueInput("font").setCheck("font family").setAlign(Blockly.ALIGN_RIGHT).appendField("font");
this.setPreviousStatement(true);
this.setNextStatement(true);
}
};
2) I would like to have a 'set_text_attributes' block in the toolbox with a default input font block. So in my XML definition of the toolbox I added the block below, but I get an exception 'Uncaught ReferenceError: prototypeName is not defined'.
Alas I didn't find a similar example.
<block type="set_text_attributes">
......
<value name="font">
<block type="font family">
<field name="font">helvetica</field>
</block>
</value>
</block>
thanks
David