add_action_to_menu

omni.kit.menu.utils.scripts.utils.add_action_to_menu(menu_path: str, on_action: Callable, action_name: Optional[str] = None, default_hotkey: Optional[Tuple[int, int]] = None, on_rmb_click: Optional[Callable] = None) ActionMenuSubscription

Add action to menu path. (deprecated)

This function binds passed callable `on_action` function with carb.input action and a menu path together. If `default_hotkey` is provided it is set into settings and appears on the menu.

Parameters
  • menu_path – menu path. E.g. “File/Open”.

  • on_action – function to be called as an action.

  • on_rmb_click – function to be called when right mouse button clicked.

  • action_name – action name. If not provided menu path is used as action, where all ‘/’ are replaced with ‘-‘.

  • default_hotkey (tuple(int, carb.input.KeyboardInput)) – modifier and key tuple to associate with given action.

Returns

Subscription holder object. Action is removed when this object is destroyed.