How to hide advanced blocks in custom extensions? #2429
-
|
I'm developing a custom Scratch extension. I know there's a bunch of Scratch APIs that I have never seen before (like the How should I go about hiding advanced blocks in my custom extension and having a button that shows/hides them, preferably storing the value on whether or not said blocks are hidden in the project? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
In your extension class, create a constructor object/variable that stores whether the section(s) is/are hidden. Then create a block with type Scratch.BlockType.BUTTON and set its function to toggle that value. By toggling Take a look at this commit for an example; I think I adapted that code from @SharkPool-SP or someone else though so don't credit me for it |
Beta Was this translation helpful? Give feedback.
In your extension class, create a constructor object/variable that stores whether the section(s) is/are hidden. Then create a block with type Scratch.BlockType.BUTTON and set its function to toggle that value. By toggling
hideFromPalletvia a variable/object and then callingScratch.vm.extensionManager.refreshBlocksyou can get the effect you're looking for.Take a look at this commit for an example; I think I adapted that code from @SharkPool-SP or someone else though so don't credit me for it