The ability to right click a block, and have an option called ‘collapse…’ that ‘collapses’ the block. If you have an absurd amount of code, this could be useful - the ability to ‘collapse’ and ‘uncollapse’ blocks to make code neater.
This feature is something you can do when you use a Blockly based system like App Inventor if it is enabled. Scratch is also Blockly based but isn’t using this feature.
is there a way to implement it though?
use custom blocks.
Wow, this thread is unhelpful.
Snap! isn’t Blockly based. It was made in Morphic.js from scratch as far as I know.
This isn’t something you can implement with custom blocks?
You kinda can, but it would be painstakingly long, and some data could be lost.
I’m thinking of trying mods again. I’ll see if I can script this thing now.
BlockMorph.prototype.isCondensed = false
BlockMorph.prototype._userMenu = BlockMorph.prototype.userMenu
// BlockMorph.prototype.userMenu = function () {} // do what I did with plib :)
BlockMorph.prototype.becomeCondensed = function () {}
BlockMorph.prototype._render = BlockMorph.prototype.render
// BlockMorph.prototype.render = function () {}
My plan is to have the right side jagged, like the prototype input blocks.
Why? OP is asking for a feature. If it ever will be done or if it is even possible is another question.
True.
use custom blocks if you want to simplify and hide code.
º: In Snavanced! (a Snap! mod), there is a special type of variadic c-slot input to collapse blocks; it is still experimental as still has errors, however you can do this in the script namer block that can be encountered in the Control category. [Redirecting to Snavanced!..]
Use block variables to store the code.
that could work, but i don’t want to constantly re-edit a block every time i add something tiny to the script
In fact, I will actually try and create a block that collapses while retaining the script.
Looks like this:
collapsible block [collapse V] {
}
i have tried to create hidden, collapsing inputs before, but its really biggy, and it kinda breaks when you have 2 or more inputs
Private
i swear i published this
Am I missing something? I still couldn’t access it.
Edit: Nevermind.
Buggy? See? This is why you should use block variables for such a purpose.
phew, i was worried i had to give the xml file
but how do i assign each independent block to an independent block?
I’m ready to share this, as it works now. This block is slightly different from what I thought would turn out to be. I am still hunting for a way to stop this block from throwing out the script it holds when collapsed.
If I renovated your comment block in a similar fashion it would have been far easier because text can be easily destroyed, whereas scripts pop out instead of vanish without a trace whenever its slot is gone, 99% sure for the good. Most importantly, the set slot block cannot handle blocks very well.
Obviously experimental; do not use in projects you value or care!
Edit: Turns out uncollapsing will not reveal the collapsed script. I wasn’t given the proper tools to fix my shoddy experimental block!
works way better than my code, but i think that making a collapsible string slot is impossible.




