Hi,
When a block is deleted, destroy() is called and the Blockly.Events.BLOCK_DELETE event is fired. This happens regardless of how the block is deleted -- it could be dragged to the trashcan or when you click "Delete Block" in the context menu.
It sounds like you want to do something only when "Delete Block" is clicked. Is this correct? If so, you could
change the callback function for the "Delete Block" template in the context menu:
const deleteTemplate = Blockly.ContextMenuRegistry.registry.getItem('blockDelete');
oldDeleteCallback = deleteTemplate.callback;
deleteTemplate.callback = function(scope, e) {
doSomething();
oldDeleteCallback(scope, e);
};
I'm curious why it matters how the block is deleted -- I'm wondering if there is a better way to solve this.
Ronald Bourret
Technical Writer (Provided by Synergis)