It's clear there's at least some level of validation for block connections in Blockly, since value inputs can reject blocks if the type doesn't match.
I would like to perform validation on a statement input. My block should allow some types of blocks to be connected inside of it while rejecting others.
I've tried implementing an onChange handler that uses block.unplug(true) if it ever detects an invalid child. I've also tried calling workspace.undo() in the same function. Both of these have problems, though:
* block.unplug() kicks the erroneous block into an arbitrary nearby position, and if you try to drop in a stack of blocks it splits them up.
* workspace.undo() removes new blocks from the workspace if they were dropped in from the toolbox.
In both cases, it doesn't match the behavior of type-based validation, and additionally any shadow blocks that were previously present aren't restored.
Is there a straightforward way to do this that I'm missing?
/s/ Adam