Blockly. Events
Events fired as a result of actions in Blockly's editor.
Classes
Abstract
Abstract class for an event.
BlockBase
Abstract class for a block event.
BlockChange
Class for a block change event.
BlockCreate
Class for a block creation event.
BlockDelete
Class for a block deletion event.
BlockDrag
Class for a block drag event.
BlockMove
Class for a block move event. Created before the move.
BubbleOpen
Class for a bubble open event.
Change
Class for a block change event.
Click
Class for a click event.
CommentBase
Abstract class for a comment event.
CommentChange
Class for a comment change event.
CommentCreate
Class for a comment creation event.
CommentDelete
Class for a comment deletion event.
CommentMove
Class for a comment move event. Created before the move.
Create
Class for a block creation event.
Delete
Class for a block deletion event.
FinishedLoading
Class for a finished loading event. Used to notify the developer when the workspace has finished loading (i.e domToWorkspace). Finished loading events do not record undo or redo.
MarkerMove
Class for a marker move event.
Move
Class for a block move event. Created before the move.
Selected
Class for a selected event.
ThemeChange
Class for a theme change event.
ToolboxItemSelect
Class for a toolbox item select event.
TrashcanOpen
Class for a trashcan open event.
Ui
Class for a UI event.
UiBase
Base class for a UI event. UI events are events that don't need to be sent over the wire for multi-user editing to work (e.g. scrolling the workspace, zooming, opening toolbox categories). UI events do not undo or redo.
VarBase
Abstract class for a variable event.
VarCreate
Class for a variable creation event.
VarDelete
Class for a variable deletion event.
VarRename
Class for a variable rename event.
ViewportChange
Class for a viewport change event.
Properties
BLOCK_CHANGE
Name of event that changes a block.
BLOCK_CREATE
Name of event that creates a block.
BLOCK_DELETE
Name of event that deletes a block.
BLOCK_DRAG
Name of event that record a block drags a block.
BLOCK_MOVE
Name of event that moves a block.
BUBBLE_OPEN
Name of event that records a bubble open.
BUMP_EVENTS
List of events that cause objects to be bumped back into the visible portion of the workspace.
Not to be confused with bumping so that disconnected connections do not appear connected.
CHANGE
Name of event that changes a block. Will be deprecated for BLOCK_CHANGE.
CLICK
Name of event that records a click.
COMMENT_CHANGE
Name of event that changes a comment.
COMMENT_CREATE
Name of event that creates a comment.
COMMENT_DELETE
Name of event that deletes a comment.
COMMENT_MOVE
Name of event that moves a comment.
CREATE
Name of event that creates a block. Will be deprecated for BLOCK_CREATE.
DELETE
Name of event that deletes a block. Will be deprecated for BLOCK_DELETE.
FINISHED_LOADING
Name of event that records a workspace load.
MARKER_MOVE
Name of event that records a marker move.
MOVE
Name of event that moves a block. Will be deprecated for BLOCK_MOVE.
recordUndo
boolean
Sets whether the next event should be added to the undo stack.
SELECTED
Name of event that records a change in selected element.
THEME_CHANGE
Name of event that records a theme change.
TOOLBOX_ITEM_SELECT
Name of event that records a toolbox item select.
TRASHCAN_OPEN
Name of event that records a trashcan open.
UI
Name of generic event that records a UI change.
VAR_CREATE
Name of event that creates a variable.
VAR_DELETE
Name of event that deletes a variable.
VAR_RENAME
Name of event that renames a variable.
VIEWPORT_CHANGE
Name of event that records a viewport change.
Methods
clearPendingUndo
clearPendingUndo()
Modify pending undo events so that when they are fired they don't land in the undo stack. Called by Blockly.Workspace.clearUndo.
CommentCreateDeleteHelper
CommentCreateDeleteHelper(event, create)
Helper function for Comment[Create|Delete]
Parameter |
|
---|---|
event |
(non-null Blockly.Events.CommentCreate or non-null Blockly.Events.CommentDelete) The event to run. |
create |
boolean if True then Create, if False then Delete |
disable
disable()
Stop sending events. Every call to this function MUST also call enable.
disableOrphans
disableOrphans(event)
Enable/disable a block depending on whether it is properly connected. Use this on applications where all blocks should be connected to a top block. Recommend setting the 'disable' option to 'false' in the config so that users don't try to re-enable disabled orphan blocks.
Parameter |
|
---|---|
event |
Custom data for event. Value must not be null. |
enable
enable()
Start sending events. Unless events were already disabled when the corresponding call to disable was made.
filter
filter(queueIn, forward) returns Array of non-null Blockly.Events.Abstract
Filter the queued events and merge duplicates.
Parameter |
|
---|---|
queueIn |
Array of non-null Blockly.Events.Abstract Array of events. Value must not be null. |
forward |
boolean True if forward (redo), false if backward (undo). |
- Returns
-
non-null Array of non-null Blockly.Events.Abstract
Array of filtered events.
fire
fire(event)
Create a custom event and fire it.
Parameter |
|
---|---|
event |
Custom data for event. Value must not be null. |
fromJson
fromJson(json, workspace) returns Blockly.Events.Abstract
Decode the JSON into an event.
Parameter |
|
---|---|
json |
Object JSON representation. Value must not be null. |
workspace |
Target workspace for event. Value must not be null. |
- Throws
-
Error
if an event type is not found in the registry. - Returns
-
non-null Blockly.Events.Abstract
The event represented by the JSON.
get
get(eventType) returns function()
Gets the class for a specific event type from the registry.
Parameter |
|
---|---|
eventType |
string The type of the event to get. |
- Returns
-
nullable function(constructs Blockly.Events.Abstract, repeatable unknown)
The event class with the given type or null if none exists.
getDescendantIds
getDescendantIds(block) returns Array of string
Compute a list of the IDs of the specified block and all its descendants.
Parameter |
|
---|---|
block |
The root block. Value must not be null. |
- Returns
-
non-null Array of string
List of block IDs.
getGroup
getGroup() returns string
Current group.
- Returns
-
string
ID string.
isEnabled
isEnabled() returns boolean
Returns whether events may be fired or not.
- Returns
-
boolean
True if enabled.
setGroup
setGroup(state)
Start or stop a group.
Parameter |
|
---|---|
state |
(boolean or string) True to start new group, false to end group. String to set group explicitly. |
Abstract type
BumpEvent
(non-null Blockly.Events.BlockCreate, non-null Blockly.Events.BlockMove, non-null Blockly.Events.CommentCreate, or non-null Blockly.Events.CommentMove)
Type of events that cause objects to be bumped back into the visible portion of the workspace.
Not to be confused with bumping so that disconnected connections do not appear connected.