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
| 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. |
| element | The element that changed; one of 'field', 'comment', 'collapsed', 'disabled', 'inline', or 'mutation' |
| name | The name of the field that changed, if this is a change to a field. |
| oldValue | The original value of the element. |
| newValue | The new value of the element. |
Methods index
| Method | Description |
|---|---|
| getEventWorkspace_ | Get workspace the event belongs to. |
| toJson | Encode the event as JSON. |
| setDisabledReason | 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'. |
| isNull | Does this event record any change of state? |
| run | Run 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
| Parameter | Type | Description |
|---|---|---|
opt_block? | Block | The changed block. Undefined for a blank event. |
opt_element? | string | One of 'field', 'comment', 'disabled', etc. |
opt_name? | string | null | Name of input or field affected, or null. |
opt_oldValue? | unknown | Previous value of element. |
opt_newValue? | unknown | New value of element. |
Returns
BlockChange
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_CHANGE;
Defined in: packages/blockly/core/events/events_block_change.ts:32
Type of this event.
Overrides
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
The workspace the event belongs to.
Throws
if workspace is null.
Inherited from
toJson()
toJson(): BlockChangeJson;
Defined in: packages/blockly/core/events/events_block_change.ts:84
Encode the event as JSON.
Returns
JSON representation.
Overrides
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
| Parameter | Type | Description |
|---|---|---|
disabledReason | string | The 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
run()
run(forward): void;
Defined in: packages/blockly/core/events/events_block_change.ts:163
Run a change event.
Parameters
| Parameter | Type | Description |
|---|---|---|
forward | boolean | True if run forward, false if run backward (undo). |
Returns
void