add_menu

omni.kit.widget.context_menu.custom_menu_dict.add_menu(menu_dict, index: str = 'MENU', extension_id: str = '')

Add custom menu to any context_menu

Examples

menu = {“name”: “Open in Material Editor”, “onclick_fn”: open_material} # add to all context menus self._my_custom_menu = omni.kit.context_menu.add_menu(menu, “MENU”, “”) # add to omni.kit.widget.stage context menu self._my_custom_menu = omni.kit.context_menu.add_menu(menu, “MENU”, “omni.kit.widget.stage”)

Parameters
  • menu_dict – a dictionary containing menu settings. See ContextMenuExtension docs for information on values

  • index – name of the menu EG. “MENU”

  • extension_id – name of the target EG. “” or “omni.kit.widget.stage”

NOTE: index and extension_id are extension arbitrary values. add_menu(menu, “MENU”, “omni.kit.widget.stage”) works

as omni.kit.widget.stage retrieves custom context_menus with get_menu_dict(“MENU”, “omni.kit.widget.stage”) Adding a menu to an extension that doesn’t support context_menus would have no effect.

Returns

A MenuSubscription, keep a copy of this as the custom menu will be removed when `release()`

is explicitly called or this is garbage collected.

Return type

(MenuSubscription)