How to disable delete function of the toolbox when a block is dropped on it.

110 views
Skip to first unread message

Donnie Y

unread,
Jun 2, 2023, 3:22:24 AM6/2/23
to Blockly
Hello,

I want to disable a delete function of the toolbox when a block is dropped on it.
I want the trashcan to be the only way to delete a block by dragging.

I tried to search for a documentation i couldn't find any related information.
And it seems like there is no option in the ToolboxOption.

Can anybody help me solve this issue?

I would really appreciate your guidence!

Thank you,
Donnie

Dev O

unread,
Jun 2, 2023, 4:25:40 AM6/2/23
to Blockly
Check the documentation. I think this can be achieved by setting the following: (editable:false).

Christopher Allen

unread,
Jun 2, 2023, 12:41:21 PM6/2/23
to blo...@googlegroups.com
Hi Donnie,

On Fri, 2 Jun 2023 at 08:22, Donnie Y <krmt...@gmail.com> wrote:

I want to disable a delete function of the toolbox when a block is dropped on it.
I want the trashcan to be the only way to delete a block by dragging.

This can be done by removing the DELETE_AREA capability from the toolbox:

// Create workspae in the usual way:
const workspace = Blockly.inject(/* omitted */);

// Get Toolbox instance, remove DELETE_AREA capability:
const toolbox = workspace.getToolbox();
workspace.getComponentManager().removeCapability(
  Blockly.ComponentManager.Capability.DELETE_AREA
);

This will prevent blocks from being deleted by dragging them to the toolbox. 


Christopher

Donnie Y

unread,
Jun 4, 2023, 11:08:04 PM6/4/23
to Blockly
It is done by removing the capability.
Thank you, Christopher!

2023년 6월 3일 토요일 오전 1시 41분 21초 UTC+9에 cpca...@google.com님이 작성:
Reply all
Reply to author
Forward
0 new messages