Description
Expected Behavior
We should be able to change the set of blocks in the flyout (containing all of the blocks - PR here) without re-rendering the entire flyout (otherwise, the update will be very slow). The cases include:
- Switching to or from the stage (which excludes some blocks, and adds others)
- Creating a variable
- Switching sprites, to update the displayed local variable reporter blocks
- Adding an extension
Actual Behavior
Currently, we don't have a way to update only part of the blocks menu.
Notes from @rachel-fenichel
This means you want to remove (or add) some blocks; render any new blocks; not render any old blocks; then reflow the flyout.
Currently reflow assumes that it only needs to shuffle things horizontally (in the vertical flyout) so we'll need to modify that.
When you delete a block there are a few things that need deleting:
- the rectangle behind the block (click target)
- the block itself
- the block's checkbox, if it exists
- the mouse listeners corresponding to the block
The mouse listeners are just kept in a list right now, with no attention paid to the correspondence between listeners and blocks. You'll need to change that.
Other notes
When we update the flyout on switching sprites, the scroll position will need to be updated if the flyout has changed in length. I think the simplest thing will be to store the selected category and scroll to it after the update.