Skip to main content

Class: BlockMove

Defined in: packages/blockly/core/events/events_block_move.ts:33

Notifies listeners when a block is moved. This could be from one connection to another, or from one location on the workspace to another.

Extends​

Properties index​

PropertyDescription
workspaceIdThe workspace identifier for this event.
groupAn ID for the group of events this block is associated with.
recordUndoWhether this event is undoable or not.
isUiEventWhether or not the event is a UI event.
isBlankWhether or not the event was constructed without necessary parameters (to be populated by fromJson).
blockIdThe ID of the block associated with this event.
typeType of this event.
oldParentIdThe ID of the old parent block. Undefined if it was a top-level block.
oldInputNameThe name of the old input. Undefined if it was a top-level block or the parent's next block.
oldCoordinateThe old X and Y workspace coordinates of the block if it was a top level block. Undefined if it was not a top level block.
newParentIdThe ID of the new parent block. Undefined if it is a top-level block.
newInputNameThe name of the new input. Undefined if it is a top-level block or the parent's next block.
newCoordinateThe new X and Y workspace coordinates of the block if it is a top-level block. Undefined if it is not a top level block.
reasonAn explanation of what this move is for. Known values include: 'drag' -- A drag operation completed. 'bump' -- Block got bumped away from an invalid connection. 'snap' -- Block got shifted to line up with the grid. 'inbounds' -- Block got pushed back into a non-scrolling workspace. 'connect' -- Block got connected to another block. 'disconnect' -- Block got disconnected from another block. 'create' -- Block created via XML. 'cleanup' -- Workspace aligned top-level blocks. Event merging may create multiple reasons: ['drag', 'bump', 'snap'].

Methods index​

MethodDescription
getEventWorkspace_Get workspace the event belongs to.
toJsonEncode the event as JSON.
recordNewRecord the block's new location. Called after the move.
setReasonSet the reason for a move event.
isNullDoes this event record any change of state?
runRun a move event.

Constructors​

Constructor​

new BlockMove(opt_block?): BlockMove;

Defined in: packages/blockly/core/events/events_block_move.ts:81

Parameters​

ParameterTypeDescription
opt_block?BlockThe moved block. Undefined for a blank event.

Returns​

BlockMove

Overrides​

BlockBase.constructor

Properties​

workspaceId?​

optional workspaceId?: string = undefined;

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

The workspace identifier for this event.

Inherited from​

BlockBase.workspaceId


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​

BlockBase.group


recordUndo​

recordUndo: boolean;

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

Whether this event is undoable or not.

Inherited from​

BlockBase.recordUndo


isUiEvent​

isUiEvent: boolean = false;

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

Whether or not the event is a UI event.

Inherited from​

BlockBase.isUiEvent


isBlank​

isBlank: boolean = true;

Defined in: packages/blockly/core/events/events_block_base.ts:23

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

Inherited from​

BlockBase.isBlank


blockId?​

optional blockId?: string;

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

The ID of the block associated with this event.

Inherited from​

BlockBase.blockId


type​

type: EventType = EventType.BLOCK_MOVE;

Defined in: packages/blockly/core/events/events_block_move.ts:34

Type of this event.

Overrides​

BlockBase.type


oldParentId?​

optional oldParentId?: string;

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

The ID of the old parent block. Undefined if it was a top-level block.


oldInputName?​

optional oldInputName?: string;

Defined in: packages/blockly/core/events/events_block_move.ts:43

The name of the old input. Undefined if it was a top-level block or the parent's next block.


oldCoordinate?​

optional oldCoordinate?: Coordinate;

Defined in: packages/blockly/core/events/events_block_move.ts:49

The old X and Y workspace coordinates of the block if it was a top level block. Undefined if it was not a top level block.


newParentId?​

optional newParentId?: string;

Defined in: packages/blockly/core/events/events_block_move.ts:52

The ID of the new parent block. Undefined if it is a top-level block.


newInputName?​

optional newInputName?: string;

Defined in: packages/blockly/core/events/events_block_move.ts:58

The name of the new input. Undefined if it is a top-level block or the parent's next block.


newCoordinate?​

optional newCoordinate?: Coordinate;

Defined in: packages/blockly/core/events/events_block_move.ts:64

The new X and Y workspace coordinates of the block if it is a top-level block. Undefined if it is not a top level block.


reason?​

optional reason?: string[];

Defined in: packages/blockly/core/events/events_block_move.ts:78

An explanation of what this move is for. Known values include: 'drag' -- A drag operation completed. 'bump' -- Block got bumped away from an invalid connection. 'snap' -- Block got shifted to line up with the grid. 'inbounds' -- Block got pushed back into a non-scrolling workspace. 'connect' -- Block got connected to another block. 'disconnect' -- Block got disconnected from another block. 'create' -- Block created via XML. 'cleanup' -- Workspace aligned top-level blocks. Event merging may create multiple reasons: ['drag', 'bump', 'snap'].

Methods​

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​

BlockBase.getEventWorkspace_


toJson()​

toJson(): BlockMoveJson;

Defined in: packages/blockly/core/events/events_block_move.ts:104

Encode the event as JSON.

Returns​

BlockMoveJson

JSON representation.

Overrides​

BlockBase.toJson


recordNew()​

recordNew(): void;

Defined in: packages/blockly/core/events/events_block_move.ts:170

Record the block's new location. Called after the move.

Returns​

void


setReason()​

setReason(reason): void;

Defined in: packages/blockly/core/events/events_block_move.ts:182

Set the reason for a move event.

Parameters​

ParameterTypeDescription
reasonstring[]Why is this move happening? 'drag', 'bump', 'snap', ...

Returns​

void


isNull()​

isNull(): boolean;

Defined in: packages/blockly/core/events/events_block_move.ts:226

Does this event record any change of state?

Returns​

boolean

False if something changed.

Overrides​

BlockBase.isNull


run()​

run(forward): void;

Defined in: packages/blockly/core/events/events_block_move.ts:239

Run a move event.

Parameters​

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

Returns​

void

Overrides​

BlockBase.run