Class: ContextMenuRegistry
Defined in: packages/blockly/core/contextmenu_registry.ts:25
Class for the registry of context menu items. This is intended to be a singleton. You should not create a new instance, and only access this class from ContextMenuRegistry.registry.
Properties index
| Property | Description |
|---|---|
| registry | - |
Methods index
| Method | Description |
|---|---|
| reset | Clear and recreate the registry. |
| register | Registers a RegistryItem. |
| unregister | Unregisters a RegistryItem with the given ID. |
| getItem | Returns registryItem or null if not found |
| getContextMenuOptions | Gets the valid context menu options for the given scope. Options are only included if the preconditionFn shows they should not be hidden. |
Constructors
Constructor
new ContextMenuRegistry(): ContextMenuRegistry;
Defined in: packages/blockly/core/contextmenu_registry.ts:31
Resets the existing singleton instance of ContextMenuRegistry.
Returns
ContextMenuRegistry
Properties
registry
static registry: ContextMenuRegistry;
Defined in: packages/blockly/core/contextmenu_registry.ts:26
Methods
reset()
reset(): void;
Defined in: packages/blockly/core/contextmenu_registry.ts:36
Clear and recreate the registry.
Returns
void
register()
register(item): void;
Defined in: packages/blockly/core/contextmenu_registry.ts:46
Registers a RegistryItem.
Parameters
| Parameter | Type | Description |
|---|---|---|
item | RegistryItem | Context menu item to register. |
Returns
void
Throws
if an item with the given ID already exists.
unregister()
unregister(id): void;
Defined in: packages/blockly/core/contextmenu_registry.ts:59
Unregisters a RegistryItem with the given ID.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The ID of the RegistryItem to remove. |
Returns
void
Throws
if an item with the given ID does not exist.
getItem()
getItem(id):
| RegistryItem
| null;
Defined in: packages/blockly/core/contextmenu_registry.ts:70
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The ID of the RegistryItem to get. |
Returns
| RegistryItem
| null
RegistryItem or null if not found
getContextMenuOptions()
getContextMenuOptions(scope, menuOpenEvent): ContextMenuOption[];
Defined in: packages/blockly/core/contextmenu_registry.ts:84
Gets the valid context menu options for the given scope. Options are only included if the preconditionFn shows they should not be hidden.
Parameters
| Parameter | Type | Description |
|---|---|---|
scope | Scope | Current scope of context menu (i.e., the exact workspace or block being clicked on). |
menuOpenEvent | Event | Event that caused the menu to open. |
Returns
the list of ContextMenuOptions