Skip to main content

Class: BlockChange

Defined in: packages/blockly/core/events/events_block_change.ts:31

Notifies listeners when some element of a block has changed (e.g. field values, comments, etc).

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.
elementThe element that changed; one of 'field', 'comment', 'collapsed', 'disabled', 'inline', or 'mutation'
nameThe name of the field that changed, if this is a change to a field.
oldValueThe original value of the element.
newValueThe new value of the element.

Methods index

MethodDescription
getEventWorkspace_Get workspace the event belongs to.
toJsonEncode the event as JSON.
setDisabledReasonSet the language-neutral identifier for the reason why the block was or was not disabled. This is only valid for events where element is 'disabled'. Defaults to 'MANUALLY_DISABLED'.
isNullDoes this event record any change of state?
runRun a change event.

Constructors

Constructor

new BlockChange(
opt_block?,
opt_element?,
opt_name?,
opt_oldValue?,
opt_newValue?
): BlockChange;

Defined in: packages/blockly/core/events/events_block_change.ts:61

Parameters

ParameterTypeDescription
opt_block?BlockThe changed block. Undefined for a blank event.
opt_element?stringOne of 'field', 'comment', 'disabled', etc.
opt_name?string | nullName of input or field affected, or null.
opt_oldValue?unknownPrevious value of element.
opt_newValue?unknownNew value of element.

Returns

BlockChange

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:25

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:28

The ID of the block associated with this event.

Inherited from

BlockBase.blockId


type

type: EventType = EventType.BLOCK_CHANGE;

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

Type of this event.

Overrides

BlockBase.type


element?

optional element?: string;

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

The element that changed; one of 'field', 'comment', 'collapsed', 'disabled', 'inline', or 'mutation'


name?

optional name?: string;

Defined in: packages/blockly/core/events/events_block_change.ts:40

The name of the field that changed, if this is a change to a field.


oldValue

oldValue: unknown;

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

The original value of the element.


newValue

newValue: unknown;

Defined in: packages/blockly/core/events/events_block_change.ts:46

The new value of the element.

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(): BlockChangeJson;

Defined in: packages/blockly/core/events/events_block_change.ts:84

Encode the event as JSON.

Returns

BlockChangeJson

JSON representation.

Overrides

BlockBase.toJson


setDisabledReason()

setDisabledReason(disabledReason): void;

Defined in: packages/blockly/core/events/events_block_change.ts:139

Set the language-neutral identifier for the reason why the block was or was not disabled. This is only valid for events where element is 'disabled'. Defaults to 'MANUALLY_DISABLED'.

Parameters

ParameterTypeDescription
disabledReasonstringThe identifier of the reason why the block was or was not disabled.

Returns

void


isNull()

isNull(): boolean;

Defined in: packages/blockly/core/events/events_block_change.ts:154

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_change.ts:163

Run a change event.

Parameters

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

Returns

void

Overrides

BlockBase.run