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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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:
giving it a callback function which uses workspace.getVariablesOfType('SomeType') to get a list of the variables of the desired type,
and then creates toolbox entries for blocks for those variables.
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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Blockly
Never mind. Solved with
delete Blockly.Blocks['math_change']; -- thanks to Mark.