Class: DeleteArea

Constructor

DeleteArea

new DeleteArea()

Abstract class for a component that can delete a block or bubble that is dropped on top of it.

Extends
Blockly.DragTarget
Implements
Blockly.IDeleteArea

Properties

getClientRect

Returns the bounding rectangle of the drag target area in pixel units relative to the Blockly injection div.

Inherited from
Blockly.DragTarget#getClientRect
Implements
Blockly.IDragTarget#getClientRect
Blockly.IDeleteArea#getClientRect
Returns

The component's bounding box. Null if drag target area should be ignored.

wouldDelete_

protected

boolean

Whether the last block or bubble dragged over this delete area would be deleted if dropped on this component. This property is not updated after the block or bubble is deleted.

Methods

onDragEnter

onDragEnter(_dragElement)

Handles when a cursor with a block or bubble enters this drag target.

Parameter

_dragElement

The block or bubble currently being dragged.

Value must not be null.

Inherited from
Blockly.DragTarget#onDragEnter
Implements
Blockly.IDragTarget#onDragEnter
Blockly.IDeleteArea#onDragEnter

onDragExit

onDragExit(_dragElement)

Handles when a cursor with a block or bubble exits this drag target.

Parameter

_dragElement

The block or bubble currently being dragged.

Value must not be null.

Inherited from
Blockly.DragTarget#onDragExit
Implements
Blockly.IDragTarget#onDragExit
Blockly.IDeleteArea#onDragExit

onDragOver

onDragOver(_dragElement)

Handles when a cursor with a block or bubble is dragged over this drag target.

Parameter

_dragElement

The block or bubble currently being dragged.

Value must not be null.

Inherited from
Blockly.DragTarget#onDragOver
Implements
Blockly.IDragTarget#onDragOver
Blockly.IDeleteArea#onDragOver

onDrop

onDrop(_dragElement)

Handles when a block or bubble is dropped on this component. Should not handle delete here.

Parameter

_dragElement

The block or bubble currently being dragged.

Value must not be null.

Inherited from
Blockly.DragTarget#onDrop
Implements
Blockly.IDragTarget#onDrop
Blockly.IDeleteArea#onDrop

shouldPreventMove

shouldPreventMove(_dragElement) returns boolean

Returns whether the provided block or bubble should not be moved after being dropped on this component. If true, the element will return to where it was when the drag started.

Parameter

_dragElement

The block or bubble currently being dragged.

Value must not be null.

Inherited from
Blockly.DragTarget#shouldPreventMove
Implements
Blockly.IDragTarget#shouldPreventMove
Blockly.IDeleteArea#shouldPreventMove
Returns

Whether the block or bubble provided should be returned to drag start.

updateWouldDelete_

protected

updateWouldDelete_(wouldDelete)

Updates the internal wouldDelete_ state.

Parameter

wouldDelete

boolean

The new value for the wouldDelete state.

wouldDelete

wouldDelete(element, couldConnect) returns boolean

Returns whether the provided block or bubble would be deleted if dropped on this area. This method should check if the element is deletable and is always called before onDragEnter/onDragOver/onDragExit.

Parameter

element

Blockly.IDraggable

The block or bubble currently being dragged.

Value must not be null.

couldConnect

boolean

Whether the element could could connect to another.

Implements
Blockly.IDeleteArea#wouldDelete
Returns

boolean Whether the element provided would be deleted if dropped on this area.