Stay organized with collections
Save and categorize content based on your preferences.
blockly > Workspace > newBlock
Workspace.newBlock() method
Obtain a newly created block.
Signature:
newBlock(prototypeName: string, opt_id?: string): Block;
Parameters
Parameter |
Type |
Description |
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. |
Returns:
Block
The created block.
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.
[[["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 2024-09-18 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eWorkspace.newBlock()\u003c/code\u003e method creates a new block within a Blockly workspace.\u003c/p\u003e\n"],["\u003cp\u003eIt requires the \u003ccode\u003eprototypeName\u003c/code\u003e to define the block's type and an optional \u003ccode\u003eopt_id\u003c/code\u003e for specific identification.\u003c/p\u003e\n"],["\u003cp\u003eThe method returns the newly created \u003ccode\u003eBlock\u003c/code\u003e object for further manipulation within the workspace.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [Workspace](./blockly.workspace_class.md) \\\u003e [newBlock](./blockly.workspace_class.newblock_1_method.md)\n\nWorkspace.newBlock() method\n\nObtain a newly created block.\n\n**Signature:** \n\n newBlock(prototypeName: string, opt_id?: string): Block;\n\nParameters\n\n| Parameter | Type | Description |\n|---------------|--------|--------------------------------------------------------------------------------|\n| prototypeName | string | Name of the language object containing type-specific functions for this block. |\n| opt_id | string | *(Optional)* Optional ID. Use this ID if provided, otherwise create a new ID. |\n\n**Returns:**\n\n[Block](./blockly.block_class.md)\n\nThe created block."]]