Class: BlockMove
Defined in: packages/blockly/core/events/events_block_move.ts:32
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
| Property | Description |
|---|---|
| workspaceId | The workspace identifier for this event. |
| group | An ID for the group of events this block is associated with. |
| recordUndo | Whether this event is undoable or not. |
| isUiEvent | Whether or not the event is a UI event. |
| isBlank | Whether or not the event was constructed without necessary parameters (to be populated by fromJson). |
| blockId | The ID of the block associated with this event. |
| type | Type of this event. |
| oldParentId | The ID of the old parent block. Undefined if it was a top-level block. |
| oldInputName | The name of the old input. Undefined if it was a top-level block or the parent's next block. |
| oldCoordinate | 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 | The ID of the new parent block. Undefined if it is a top-level block. |
| newInputName | The name of the new input. Undefined if it is a top-level block or the parent's next block. |
| newCoordinate | 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 | 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 index
| Method | Description |
|---|---|
| getEventWorkspace_ | Get workspace the event belongs to. |
| toJson | Encode the event as JSON. |
| recordNew | Record the block's new location. Called after the move. |
| setReason | Set the reason for a move event. |
| isNull | Does this event record any change of state? |
| run | Run a move event. |
Constructors
Constructor
new BlockMove(opt_block?): BlockMove;
Defined in: packages/blockly/core/events/events_block_move.ts:80
Parameters
| Parameter | Type | Description |
|---|---|---|
opt_block? | Block | The moved block. Undefined for a blank event. |
Returns
BlockMove
Overrides
Properties
workspaceId?
optional workspaceId?: string = undefined;
Defined in: packages/blockly/core/events/events_abstract.ts:30
The workspace identifier for this event.
Inherited from
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
recordUndo
recordUndo: boolean;
Defined in: packages/blockly/core/events/events_abstract.ts:41
Whether this event is undoable or not.
Inherited from
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
isBlank
isBlank: boolean = true;
Defined in: packages/blockly/core/events/events_block_base.ts:25
Whether or not the event was constructed without necessary parameters (to be populated by fromJson).
Inherited from
blockId?
optional blockId?: string;
Defined in: packages/blockly/core/events/events_block_base.ts:28
The ID of the block associated with this event.
Inherited from
type
type: EventType = EventType.BLOCK_MOVE;
Defined in: packages/blockly/core/events/events_block_move.ts:33
Type of this event.
Overrides
oldParentId?
optional oldParentId?: string;
Defined in: packages/blockly/core/events/events_block_move.ts:36
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:42
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:48
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:51
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:57
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:63
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:77
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
The workspace the event belongs to.
Throws
if workspace is null.
Inherited from
toJson()
toJson(): BlockMoveJson;
Defined in: packages/blockly/core/events/events_block_move.ts:103
Encode the event as JSON.
Returns
JSON representation.
Overrides
recordNew()
recordNew(): void;
Defined in: packages/blockly/core/events/events_block_move.ts:169
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:181
Set the reason for a move event.
Parameters
| Parameter | Type | Description |
|---|---|---|
reason | string[] | Why is this move happening? 'drag', 'bump', 'snap', ... |
Returns
void
isNull()
isNull(): boolean;
Defined in: packages/blockly/core/events/events_block_move.ts:225
Does this event record any change of state?
Returns
boolean
False if something changed.
Overrides
run()
run(forward): void;
Defined in: packages/blockly/core/events/events_block_move.ts:238
Run a move event.
Parameters
| Parameter | Type | Description |
|---|---|---|
forward | boolean | True if run forward, false if run backward (undo). |
Returns
void