New to Blockly - is there a reference list for the names of Blocks within blockly

2,248 views
Skip to first unread message

Handel Callender

unread,
Apr 25, 2018, 11:43:36 AM4/25/18
to Blockly
Hello all,

this may seem like a dumb question, but if I am building a custom block or even generating a default block, lets say a do / while loop, how do I know what text Blockly will recognize in order to produce that block?  In otherwords, is there a reference list of the names of the multitude of default blocks contained within Blockly?

Many thanks for any help offered

picklesrus

unread,
Apr 25, 2018, 12:07:16 PM4/25/18
to Blockly
The link between the block definition and a block showing up in the toolbox is the block type.  All the sample blocky block definitions live in this directory: https://github.com/google/blockly/tree/master/blocks  They're broken up into different files by category.

If I'm looking for to find the definition of a block in the blockly playground (the toolbox there has most, if not all, of the useful sample blocks), I find the easiest thing to do is drag that block into the workspace, click the "Export to XML" button.  In the XML, I look for the "type" attribute in the <block> tag and then go find that type in https://github.com/google/blockly/tree/master/blocks

For example, there's a block in the logic category that does comparisons. (See attached screenshot) That block has type "logic_compare" so I went and search for that in the blocks directory finding https://github.com/google/blockly/blob/7679d227df8f62a12316334ee708d4a9a800ef17/blocks/logic.js#L123

Hope that helps!
picklesrus
Screen Shot 2018-04-25 at 9.02.24 AM.png

Handel Callender

unread,
Apr 25, 2018, 2:11:15 PM4/25/18
to Blockly
This is so GREAT!!!  Thank you so much for the help!

Just out of curiosity, why was this so hard to find as a beginner? :) Did I miss something in my initial researching into Blockly, or in the basic introductions?

Best,
Handel

Larry Kluger

unread,
Jun 20, 2019, 12:27:43 PM6/20/19
to Blockly
I'm looking for a reference guide to the toolbox XML format for blocks. The attached message is helpful, but is there a reference page? I have only found the toolbox intro guide, https://developers.google.com/blockly/guides/configure/web/toolbox

Thank you for the great sw.

Beka Westberg

unread,
Jun 20, 2019, 6:06:48 PM6/20/19
to Blockly
Hello,

So sadly there's no reference guide, but there are a few places you can look. The toolbox page you linked is one of them, as is the playground linked above. The one other place I know of is the developer tools which allow you to build a toolbox using an editor, and then export the XML.

Sorry I couldn't exactly provide you a reference, but I hope the developer tools, as well as the other pages, will help you get started. If you have any further questions please ask :D
Beka

Erik Pasternak

unread,
Jun 21, 2019, 1:59:52 PM6/21/19
to Blockly
Yeah, the Toolbox guide you linked is the main documentation that talks about the xml format. There's also some concrete examples in the CodeLab for beginners.

Amber B

unread,
Jun 21, 2019, 2:03:31 PM6/21/19
to Blockly
Out of curiosity, what is your use case here? Because in all honesty, I almost never make my own Blockly XML by hand. When I'm developing blocks, I typically write the blocks, inject them into the toolbox, and fiddle around with dragging the block into the workspace until it looks good. Then if I need to save the XML for anything, I use Blockly.Xml.domToText(Blockly.Xml.workspaceToDom(workspace)) to get the XML, test loading from XML to make sure the block loads fine from XML, and call it good. And if I do need the block XML for something (say the default XML of a workspace), then I just do up the workspace the way I want it and grab the XML in the same fashion.

Amber B

unread,
Jun 21, 2019, 2:08:03 PM6/21/19
to Blockly
I should add, there have been a few exceptions wherein I've had to programmatically generate Blockly XML, but I always generated a sample for myself to reference using the above method first.

Larry Kluger

unread,
Jun 22, 2019, 1:43:02 PM6/22/19
to Blockly
Re: use case --

I'll be using Blockly as an interface for creating object models for an API with many options.
There are about 90 models (each will probably become a category), and each has many attributes.
The attributes will become individual blocks since most all are optional. 

This will enable users to set just the attributes they want. In addition, I can organize the blocks (attributes) within each category into most used and other "sub-categories".
(Using real sub-categories would require additional mouse actions by the users.)

So my plan is to machine-generate the toolbox XML.

You're right that I can reverse engineer from tests. But docs are always handy, so I asked.

Regards,
Larry
Reply all
Reply to author
Forward
0 new messages