Using your custom block in workspace.

210 views
Skip to first unread message

Wojciech Węgierek

unread,
Mar 6, 2016, 7:04:14 PM3/6/16
to Blockly
Hi,

I am trying to use custom block in workspace. What I have already done is my own block in a BlockFactory. Now I want to add it to toolbox and use it like any other block. How to do that?
I went through tutorial several times and I haven't found any helpful advices. Did I miss something?

Thanks in advance,
Wojtek

Avi

unread,
Mar 6, 2016, 8:13:49 PM3/6/16
to Blockly
Wojciech

Here's what I would suggest

Take a look at the source of any of the blockly demos , for example
https://blockly-demo.appspot.com/static/demos/fixed/index.html .
Copy the source to a local file or any file on your webserver.

Then, in the file  do the following ..
1) Adjust the javascript script tags to point to your location of Blockly.

<script src="my/location/wherever/blockly_compressed.js">
</script>

2) Add your own javascript files for your custom blocks . The block factory should have given you the rudimentary javascript.

<script src="my/location/wherever/my_custom.js">
</script>

3) Add your custom blocks to the toolbox.

<xml id="toolbox" style="display: none">
    <block type="standard_block1"></block>
    <block type="my_custom_block1"></block>
    <block type="my_custom_block2"></block>
</xml>

That is all there is to it.

You could choose if you want to make your Blockly fixed size or resizable. Just pick the right html file to start with and change a few things.
Later you could make categories within the toolbox to add standard and custom blocks in a neater way. Furthermore, you could now make blockly generate the code for your blocks.

Hope this helps.
Regards
Avi

Reply all
Reply to author
Forward
0 new messages