How to removed dragged blocks by clicking button in UI using program

70 views
Skip to first unread message

Prabha Kumari

unread,
Sep 10, 2021, 2:05:49 PM9/10/21
to Blockly
Hi, i want to remove the dragged blocks by clicking the reset button but only one block got deleted not the second one

<-----code---->

function reset() {
  if (Blockly.selected && !Blockly.selected.workspace.isFlyout) {
    Blockly.Events.setGroup(true);
    Blockly.hideChaff();
    Blockly.selected.dispose(/* heal */false);
    Blockly.Events.setGroup(false);
}
  delete inputTextValue;
  redrawUi();
}

Please help me with problem!!

Aaron Dodson

unread,
Sep 10, 2021, 2:29:07 PM9/10/21
to Blockly
It looks like your code is only deleting the selected block; was the second block you refer to connected to the selected block (and if so, was it a child or a parent block), or were they detached? If you just want to delete all blocks when the reset button is pressed, Blockly.getMainWorkspace().getTopBlocks() will get you all the top-level blocks, and if you loop through and delete those I believe their child blocks will be removed as well.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages