Stay organized with collections
Save and categorize content based on your preferences.
blockly > Events > BlockCreate
Events.BlockCreate class
Notifies listeners when a block (or connected stack of blocks) is created.
Signature:
export declare class BlockCreate extends BlockBase
Extends: BlockBase
Constructors
Properties
Property |
Modifiers |
Type |
Description |
ids? |
|
string[] |
(Optional) All of the IDs of created blocks. |
json? |
|
blocks.State |
(Optional) The JSON respresentation of the created block(s). |
type |
|
EventType |
|
xml? |
|
Element | DocumentFragment |
(Optional) The XML representation of the created block(s). |
Methods
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-16 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eEvents.BlockCreate\u003c/code\u003e class in Blockly notifies listeners when a new block or stack of blocks is created within the workspace.\u003c/p\u003e\n"],["\u003cp\u003eIt provides properties like \u003ccode\u003eids\u003c/code\u003e, \u003ccode\u003ejson\u003c/code\u003e, and \u003ccode\u003exml\u003c/code\u003e to access information about the created blocks in various formats.\u003c/p\u003e\n"],["\u003cp\u003eThis event class extends \u003ccode\u003eBlockBase\u003c/code\u003e and includes methods like \u003ccode\u003erun\u003c/code\u003e to execute the creation event and \u003ccode\u003etoJson\u003c/code\u003e for JSON encoding.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can utilize the \u003ccode\u003eBlockCreate\u003c/code\u003e event to track and respond to block creation actions within their Blockly applications.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [Events](./blockly.events_namespace.md) \\\u003e [BlockCreate](./blockly.events_namespace.blockcreate_class.md)\n\nEvents.BlockCreate class\n\nNotifies listeners when a block (or connected stack of blocks) is created.\n\n**Signature:** \n\n export declare class BlockCreate extends BlockBase \n\n**Extends:** [BlockBase](./blockly.events_namespace.blockbase_class.md)\n\nConstructors\n\n| Constructor | Modifiers | Description |\n|---------------------------------------------------------------------------------------------------------|-----------|------------------------------------------------------|\n| [(constructor)(opt_block)](./blockly.events_namespace.blockcreate_class._constructor__1_constructor.md) | | Constructs a new instance of the `BlockCreate` class |\n\nProperties\n\n| Property | Modifiers | Type | Description |\n|------------------------------------------------------------------------|-----------|---------------------------------------------------------------------------------------|----------------------------------------------------------------|\n| [ids?](./blockly.events_namespace.blockcreate_class.ids_property.md) | | string\\[\\] | *(Optional)* All of the IDs of created blocks. |\n| [json?](./blockly.events_namespace.blockcreate_class.json_property.md) | | [blocks.State](./blockly.serialization_namespace.blocks_namespace.state_interface.md) | *(Optional)* The JSON respresentation of the created block(s). |\n| [type](./blockly.events_namespace.blockcreate_class.type_property.md) | | EventType | |\n| [xml?](./blockly.events_namespace.blockcreate_class.xml_property.md) | | Element \\| DocumentFragment | *(Optional)* The XML representation of the created block(s). |\n\nMethods\n\n| Method | Modifiers | Description |\n|------------------------------------------------------------------------------|-----------|---------------------------|\n| [run(forward)](./blockly.events_namespace.blockcreate_class.run_1_method.md) | | Run a creation event. |\n| [toJson()](./blockly.events_namespace.blockcreate_class.tojson_1_method.md) | | Encode the event as JSON. |"]]