Hello,
I can think of a few ways to accomplish this so I'll share them all.
1. Always enable the child blocks, and when one is created, also create the parent block if it doesn't already exist. We have
similar logic when you paste a procedure call block that doesn't have a matching definition block.
2.
Dynamic categories. You can make this toolbox category a dynamic category that shows one of two states each time the category is opened. The dynamic category callback would check if the parent block already exists in the workspace, and pick the corresponding state to show.
3.
Event listeners. You can attach an event listener to the workspace that listens for block create and delete events and checks if they are about this type of block. If so, then
update the toolbox category correspondingly.
Another thing you will likely want is to use the `maxInstances` injection
option. This allows you to say that the parent block should only ever have one instance on the workspace, and Blockly will automatically prevent the block from being duplicated or pasted on the workspace, and actually will disable it in the toolbox automatically for you.
Another edge case you will want to look out for is if you have both parent and child blocks on the workspace already, and then the user deletes the parent block. You may already handle this by only allowing the child blocks to be connected to a stack of other LED-related blocks, and by
disabling orphan blocks, which would happen if there was a child block that wasn't connected to the parent block. Otherwise, you'll want to use event listeners to disable the child blocks on the workspace.
I would go with method 1 combined with the `maxInstances` option. That will be easiest to make sure your toolbox state is always valid, and maybe more straightforward for your users who won't have to wonder why the blocks are all disabled in the toolbox.
Hope that helps! Please let us know if you need additional assistance.
Maribeth