Re: How can I make a specific category of variables only display the variables of that category in the toolbox?

50 views
Skip to first unread message

Christopher Allen

unread,
Nov 22, 2023, 12:03:59 PM11/22/23
to blo...@googlegroups.com
Hi Zhengyang Zhuang,

How can I make a specific category of variables only display the variables of that category in the toolbox?
Sincerely appreciate your help.

I'm not sure I understand exactly what you are trying to do, but if your goal is to have a toolbox category like the default VARIABLE category but limited to just variables of a particular type (or types) then the most straight forward approach will be to:
You may find it helpful to look at the implementation of the callback that creates the default variables category, and in particular the flyoutCategoryBlocks function that it calls—though note that both use the legacy XML toolbox definition format, and you will probably find it easier to use the new JSON format instead.

You may wish to make some additional changes—for example, if you have a button that creates new variables, you may wish to have its callback create variables of the specified type.


Best wishes,

Christopher

Max Stephen Russell

unread,
Feb 17, 2025, 12:35:03 PMFeb 17
to Blockly
Does this mean that if I want to remove the math_change variable block from the built-in category, and still maintain the exact same dynamic functionality as the built-in "custom": "VARIABLE" dynamic category, I need to create a custom dynamic toolbox category?

Thanks.

Steve

Max Stephen Russell

unread,
Feb 17, 2025, 2:43:05 PMFeb 17
to Blockly
Never mind. Solved with  delete Blockly.Blocks['math_change']; -- thanks to Mark.
Reply all
Reply to author
Forward
0 new messages