Skip to main content

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​

PropertyDescription
registry-

Methods index​

MethodDescription
resetClear and recreate the registry.
registerRegisters a RegistryItem.
unregisterUnregisters a RegistryItem with the given ID.
getItemReturns registryItem or null if not found
getContextMenuOptionsGets 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​

ParameterTypeDescription
itemRegistryItemContext 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​

ParameterTypeDescription
idstringThe 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​

ParameterTypeDescription
idstringThe 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​

ParameterTypeDescription
scopeScopeCurrent scope of context menu (i.e., the exact workspace or block being clicked on).
menuOpenEventEventEvent that caused the menu to open.

Returns​

ContextMenuOption[]

the list of ContextMenuOptions