Blockly.Events. utils
Helper methods for events that are fired as a result of actions in Blockly's editor.
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.
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 Workspace.clearUndo.
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.
getRecordUndo
getRecordUndo() returns boolean
Returns whether or not events will be added to the undo stack.
- Returns
-
boolean
True if events will be added to the undo stack.
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. |
setRecordUndo
setRecordUndo(newValue)
Sets whether events should be added to the undo stack.
Parameter |
|
---|---|
newValue |
boolean True if events should be added to the undo stack. |
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.