Stay organized with collections
Save and categorize content based on your preferences.
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\u003eContextMenu\u003c/code\u003e namespace provides functions for managing and interacting with Blockly's context menus.\u003c/p\u003e\n"],["\u003cp\u003eYou can use these functions to create, display, hide, and dispose of context menus, as well as manage their interactions with blocks.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eContextMenu\u003c/code\u003e functions allow for dynamically creating and configuring blocks, placing them adjacent to the original block, via callbacks.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can retrieve the currently associated block, or set a new one, using dedicated functions within this namespace.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [ContextMenu](./blockly.contextmenu_namespace.md)\n\nContextMenu namespace\n---------------------\n\nFunctions\n---------\n\n| Function | Description |\n|--------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [callbackFactory(block, state)](./blockly.contextmenu_namespace.callbackfactory_1_function.md) | Create a callback function that creates and configures a block, then places the new block next to the original and returns it. |\n| [dispose()](./blockly.contextmenu_namespace.dispose_1_function.md) | Dispose of the menu. |\n| [getCurrentBlock()](./blockly.contextmenu_namespace.getcurrentblock_1_function.md) | Gets the block the context menu is currently attached to. It is not recommended that you use this function; instead, use the scope object passed to the context menu callback. |\n| [hide()](./blockly.contextmenu_namespace.hide_1_function.md) | Hide the context menu. |\n| [setCurrentBlock(block)](./blockly.contextmenu_namespace.setcurrentblock_1_function.md) | Sets the block the context menu is currently attached to. |\n| [show(menuOpenEvent, options, rtl, workspace, location)](./blockly.contextmenu_namespace.show_1_function.md) | Construct the menu based on the list of options and show the menu. |"]]