blockly > Events > BlockMove

Events.BlockMove class

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

Signature:

export declare class BlockMove extends BlockBase 

Extends: BlockBase

Constructors

Constructor Modifiers Description
(constructor)(opt_block) Constructs a new instance of the BlockMove class

Properties

Property Modifiers Type Description
newCoordinate? Coordinate (Optional) 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.
newInputName? string (Optional) The name of the new input. Undefined if it is a top-level block or the parent's next block.
newParentId? string (Optional) The ID of the new parent block. Undefined if it is a top-level block.
oldCoordinate? Coordinate (Optional) 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.
oldInputName? string (Optional) The name of the old input. Undefined if it was a top-level block or the parent's next block.
oldParentId? string (Optional) The ID of the old parent block. Undefined if it was a top-level block.
reason? string[] (Optional) 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'].
type string

Methods

Method Modifiers Description
isNull() Does this event record any change of state?
recordNew() Record the block's new location. Called after the move.
run(forward) Run a move event.
setReason(reason) Set the reason for a move event.
toJson() Encode the event as JSON.