Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Get mutator blocks in decompose method?

26 views
Skip to first unread message

Loren Norman

unread,
Dec 6, 2024, 12:01:56 PM12/6/24
to Blockly
Hello! Thank you for Blockly!

I've got a mutator configured to pop-over with some blocks in its toolbox, and I'd like to get access to those blocks during the `decompose` callback.

In this image, I'm talking about the blocks in the red square:
In the decompose function we have a workspace, but it is the workspace for the block on the right. How do I get to its toolbox and blocks?

What I'd like to do is simply call `block.setMutator(null)` on each block before they appear, maybe there's another way to do this?

Big thanks in advance, everyone,
Loren

Mark Friedman

unread,
Dec 6, 2024, 12:44:14 PM12/6/24
to blo...@googlegroups.com
Loren,

  It seems that the image in your post didn't get through.  Could you please try again?

-Mark


--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/blockly/0d4613ad-285b-48ec-bd3d-68ef285cfa92n%40googlegroups.com.

Loren Norman

unread,
Dec 6, 2024, 2:13:49 PM12/6/24
to Blockly
Solved at last. Posting solution for others.

In the mutator...
// ...
decompose: function(workspace) {
  const flyoutBlocks = getFlyout().getWorkspace().getTopBlocks()
  // ...do stuff with the flyout blocks before user interacts
}
// ...


Thank you for the response, Mark. Google Groups appears to be struggling under Firefox, it's throwing "too much recursion" in the console when I try to post. I'm guessing the image embed failure is related.

Regardless, the image is superfluous, merely a picture of a mutator flyout with the toolbox highlighted, as described in the text.
Reply all
Reply to author
Forward
0 new messages