Skip to main content

Class: BlockDrag

Defined in: packages/blockly/core/events/events_block_drag.ts:24

Notifies listeners when a block is being manually dragged/dropped.

Extends

Properties index

PropertyDescription
groupAn ID for the group of events this block is associated with.
blockIdThe ID of the top-level block being dragged.
isStartTrue if this is the start of a drag, false if this is the end of one.
blocksA list of all of the blocks (i.e. all descendants of the block associated with the block ID) being dragged.
typeType of this event.
isBlankWhether or not the event was constructed without necessary parameters (to be populated by fromJson).
workspaceIdThe workspace identifier for this event.
recordUndoWhether this event is undoable or not.
isUiEventWhether or not the event is a UI event.

Methods index

MethodDescription
isNullDoes this event record any change of state?
runRun an event.
getEventWorkspace_Get workspace the event belongs to.
toJsonEncode the event as JSON.

Constructors

Constructor

new BlockDrag(
opt_block?,
opt_isStart?,
opt_blocks?
): BlockDrag;

Defined in: packages/blockly/core/events/events_block_drag.ts:47

Parameters

ParameterTypeDescription
opt_block?BlockThe top block in the stack that is being dragged. Undefined for a blank event.
opt_isStart?booleanWhether this is the start of a block drag. Undefined for a blank event.
opt_blocks?Block[]The blocks affected by this drag. Undefined for a blank event.

Returns

BlockDrag

Overrides

UiBase.constructor

Properties

group

group: string;

Defined in: packages/blockly/core/events/events_abstract.ts:38

An ID for the group of events this block is associated with.

Groups define events that should be treated as an single action from the user's perspective, and should be undone together.

Inherited from

UiBase.group


blockId?

optional blockId?: string;

Defined in: packages/blockly/core/events/events_block_drag.ts:26

The ID of the top-level block being dragged.


isStart?

optional isStart?: boolean;

Defined in: packages/blockly/core/events/events_block_drag.ts:29

True if this is the start of a drag, false if this is the end of one.


blocks?

optional blocks?: Block[];

Defined in: packages/blockly/core/events/events_block_drag.ts:35

A list of all of the blocks (i.e. all descendants of the block associated with the block ID) being dragged.


type

type: EventType = EventType.BLOCK_DRAG;

Defined in: packages/blockly/core/events/events_block_drag.ts:37

Type of this event.

Overrides

UiBase.type


isBlank

isBlank: boolean = true;

Defined in: packages/blockly/core/events/events_ui_base.ts:25

Whether or not the event was constructed without necessary parameters (to be populated by fromJson).

Inherited from

UiBase.isBlank


workspaceId

workspaceId: string;

Defined in: packages/blockly/core/events/events_ui_base.ts:26

The workspace identifier for this event.

Inherited from

UiBase.workspaceId


recordUndo

recordUndo: boolean = false;

Defined in: packages/blockly/core/events/events_ui_base.ts:29

Whether this event is undoable or not.

Inherited from

UiBase.recordUndo


isUiEvent

isUiEvent: boolean = true;

Defined in: packages/blockly/core/events/events_ui_base.ts:32

Whether or not the event is a UI event.

Inherited from

UiBase.isUiEvent

Methods

isNull()

isNull(): boolean;

Defined in: packages/blockly/core/events/events_abstract.ts:91

Does this event record any change of state?

Returns

boolean

True if null, false if something changed.

Inherited from

UiBase.isNull


run()

run(_forward): void;

Defined in: packages/blockly/core/events/events_abstract.ts:100

Run an event.

Parameters

ParameterTypeDescription
_forwardbooleanTrue if run forward, false if run backward (undo).

Returns

void

Inherited from

UiBase.run


getEventWorkspace_()

getEventWorkspace_(): Workspace;

Defined in: packages/blockly/core/events/events_abstract.ts:111

Get workspace the event belongs to.

Returns

Workspace

The workspace the event belongs to.

Throws

if workspace is null.

Inherited from

UiBase.getEventWorkspace_


toJson()

toJson(): BlockDragJson;

Defined in: packages/blockly/core/events/events_block_drag.ts:62

Encode the event as JSON.

Returns

BlockDragJson

JSON representation.

Overrides

UiBase.toJson