Though this subject was discussed before - a.o. in a long-standing feature request - I’m raising it again: not as a feature request but as a request to the community: can we write code, using current Snap! features, to have custom blocks rearranged within a palette? The immediate trigger for me is I’m trying to rearrange a set of blocks for a library.
The order of custom blocks within a palette is apparently determined by the order (in time) in which they were created. My proposed basic approach to rearranging them would be:
- Make a list of the blocks to be reordered, in the desired order (block #1 may be skipped);
- Generate an unused block name (make sure it’s not used for a hidden block either, a/o for a block confined to another sprite within the project?);
- Create a new block with the unused name, and the definition of the original block (i.e. first block on the list), using
, and
;
- Copy all other properties of the list block to the new block, using the likes of
, and
;
- Find all blocks and scripts calling the original block; I wonder if scripts and blocks from other sprites within the project need to be included? and the new block itself?
- Replace each call to the original block with a call to the new block;
- Delete the original block, using
;
- Rename the new block to the old name, using
;
- Repeat steps 2+ for the next block in the list.
Request for help
Did anyone ever try building such tool? If it worked out: may I borrow it? If not: what works? and what are the remaining challenges?
And even if you did not try, do you have any suggestions?
Thx in advance!