Hello!
I am trying to add numeric shadow blocks to procedure callers, to make it easier for users to call functions (inspired by Scratch and MakeCode).
I have been able to use mutators and shadow blocks in various custom blocks, but I am not sure how to best to it with procedurer callers.
Things I have tried (in many variations):
- I originally started with legacy procedures and got it working with "quarkConnections", but switched to "block-shareable-procedures" since it nicely breaks down the various mixins.
- Hooking into procedureCallerUpdateShapeMixin.updateParameters_ or createArgInputs_ to add zero-valued shadow blocks after they run.
- Using the event handler to add to add zero-valued shadow blocks on any change when an input is empty.
This sort of works, but the shadow block values will reset to zero. If I understand correctly, these steps run before child blocks are loaded. And repeatedly so when the definition block is moved or changed. (I'd love to know why mutators seem to completely rebuild on moving, but maybe that is a question for another time).
This makes it tricky to keep track of the shadow block values. I've also tried something similar to the "argsMap_" method, to cache the numeric values and "reattach" these as needed. But since shadow blocks can't exist without a parent, this causes trouble when moving the argument order in the mutator dialog.
In the process, I reported a few upstream issues (
https://github.com/google/blockly-samples/issues?q=author%3Alaurensvalk), so now you know how I came across those :)
It would be awesome to get a few hints on the recommended way to do this. Thanks in advance!
If you think this is a useful (optional) addition, I would be happy to help get the result back into "block-shareable-procedures" for others to use.