blockly > Block > (constructor)
Block.(constructor)
Constructs a new instance of the Block
class
Signature:
constructor(workspace: Workspace, prototypeName: string, opt_id?: string);
Parameters
Parameter |
Type |
Description |
workspace |
Workspace |
The block's workspace. |
prototypeName |
string |
Name of the language object containing type-specific functions for this block. |
opt_id |
string |
(Optional) Optional ID. Use this ID if provided, otherwise create a new ID. |
Exceptions
When the prototypeName is not valid or not allowed.
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 2024-09-18 UTC.
[null,null,["Last updated 2024-09-18 UTC."],[[["The `Block` constructor creates a new block instance within a specified workspace."],["It requires a workspace, a prototype name for defining the block's functionality, and an optional ID for the block."],["If no ID is provided, a new one is automatically generated."],["An exception is thrown if the given prototype name is invalid or not permitted."]]],["The `Block` class constructor creates a new block instance within a specified `Workspace`. It requires the `Workspace` object and a `prototypeName` (a string identifying the block's type-specific functions). An optional string `opt_id` can be provided to assign a specific ID to the block; otherwise, a new ID will be generated. The constructor throws an exception if the `prototypeName` is invalid.\n"]]