Skip to main content

Class: DeleteArea

Defined in: packages/blockly/core/delete_area.ts:26

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

Extends​

Extended by​

Implements​

Properties index​

PropertyDescription
wouldDelete_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.
idThe unique id for this component that is used to register with the ComponentManager.

Methods index​

MethodDescription
wouldDeleteReturns 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.
updateWouldDelete_Updates the internal wouldDelete_ state.
onDragEnterHandles when a cursor with a block or bubble enters this drag target.
onDragOverHandles when a cursor with a block or bubble is dragged over this drag target.
onDragExitHandles when a cursor with a block or bubble exits this drag target.
onDropHandles when a block or bubble is dropped on this component. Should not handle delete here.
getClientRectReturns the bounding rectangle of the drag target area in pixel units relative to the Blockly injection div.
shouldPreventMoveReturns 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.

Constructors​

Constructor​

new DeleteArea(): DeleteArea;

Defined in: packages/blockly/core/delete_area.ts:45

Constructor for DeleteArea. Should not be called directly, only by a subclass.

Returns​

DeleteArea

Overrides​

DragTarget.constructor

Properties​

wouldDelete_​

protected wouldDelete_: boolean = false;

Defined in: packages/blockly/core/delete_area.ts:32

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.


id​

id: string;

Defined in: packages/blockly/core/delete_area.ts:39

The unique id for this component that is used to register with the ComponentManager.

Implementation of​

IDeleteArea.id

Overrides​

DragTarget.id

Methods​

wouldDelete()​

wouldDelete(element): boolean;

Defined in: packages/blockly/core/delete_area.ts:59

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.

Parameters​

ParameterTypeDescription
elementIDraggableThe block or bubble currently being dragged.

Returns​

boolean

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

Implementation of​

IDeleteArea.wouldDelete


updateWouldDelete_()​

protected updateWouldDelete_(wouldDelete): void;

Defined in: packages/blockly/core/delete_area.ts:78

Updates the internal wouldDelete_ state.

Parameters​

ParameterTypeDescription
wouldDeletebooleanThe new value for the wouldDelete state.

Returns​

void


onDragEnter()​

onDragEnter(_dragElement): void;

Defined in: packages/blockly/core/drag_target.ts:42

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

Parameters​

ParameterTypeDescription
_dragElementIDraggableThe block or bubble currently being dragged.

Returns​

void

Implementation of​

IDeleteArea.onDragEnter

Inherited from​

DragTarget.onDragEnter


onDragOver()​

onDragOver(_dragElement): void;

Defined in: packages/blockly/core/drag_target.ts:52

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

Parameters​

ParameterTypeDescription
_dragElementIDraggableThe block or bubble currently being dragged.

Returns​

void

Implementation of​

IDeleteArea.onDragOver

Inherited from​

DragTarget.onDragOver


onDragExit()​

onDragExit(_dragElement): void;

Defined in: packages/blockly/core/drag_target.ts:61

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

Parameters​

ParameterTypeDescription
_dragElementIDraggableThe block or bubble currently being dragged.

Returns​

void

Implementation of​

IDeleteArea.onDragExit

Inherited from​

DragTarget.onDragExit


onDrop()​

onDrop(_dragElement): void;

Defined in: packages/blockly/core/drag_target.ts:70

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

Parameters​

ParameterTypeDescription
_dragElementIDraggableThe block or bubble currently being dragged.

Returns​

void

Implementation of​

IDeleteArea.onDrop

Inherited from​

DragTarget.onDrop


getClientRect()​

getClientRect(): Rect | null;

Defined in: packages/blockly/core/drag_target.ts:81

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

Returns​

Rect | null

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

Implementation of​

IDeleteArea.getClientRect

Inherited from​

DragTarget.getClientRect


shouldPreventMove()​

shouldPreventMove(_dragElement): boolean;

Defined in: packages/blockly/core/drag_target.ts:94

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.

Parameters​

ParameterTypeDescription
_dragElementIDraggableThe block or bubble currently being dragged.

Returns​

boolean

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

Implementation of​

IDeleteArea.shouldPreventMove

Inherited from​

DragTarget.shouldPreventMove