Cannot use a block with a custom type in a block group in the toolbox. Can someone help?

85 views
Skip to first unread message

David Kadouch

unread,
Dec 8, 2014, 1:16:58 AM12/8/14
to blo...@googlegroups.com
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

phil cleaver

unread,
Dec 8, 2014, 6:50:15 AM12/8/14
to blo...@googlegroups.com
Hi David,

I think you need an underscore in

<block type="font family">

so it reads

<block type="font_family">

Cheers

Phil

David Kadouch

unread,
Dec 9, 2014, 1:53:11 AM12/9/14
to blo...@googlegroups.com
Hi Phil

Thanks this was helpful and I solved the problem (had a few more issues to deal with)
David


--
David Kadouch
Edtech entrepreneur - linkedingoogle+

--
You received this message because you are subscribed to a topic in the Google Groups "Blockly" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/blockly/RuawyUlUHuk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to blockly+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages