Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Menu Event Hooks

Table of contents
  1. onBuildMenuEvent
    1. Trigger
    2. Parameter
    3. Parameter example
    4. Annotation
  2. onOpenMenuEvent
    1. Trigger
    2. Parameter
    3. Parameter example
    4. Annotation
  3. onMenuEvent
    1. Parameter
    2. Parameter example
    3. Annotation

Menus can be built dynamically in OCG UI. You can define a configuration in the config.json file and then use the event hook to load the configuration and build the menu items. After that you can again use the event hook to define the behavior of the menu items.

onBuildMenuEvent

Trigger

This event will be triggered after a menu is clicked and before the menu items are built. This event hook can be used to build menu items for various views.

Parameter

export class MenuEvent {
  type: string;
  viewName?: string;
  itemName?: string;
  parameter?: any;
  menu?: any;
}

Parameter example

onbuildmenu.png

Annotation

  • Using event.viewName to determine from which view the event is fired
  • Using event.resourceName to determine resource type name (including virtual type name)
  • event.parameter is an instance of the context resource, from which the event is fired
  • event.menu is an instance of the menu (of type ActionMenuComponent), you can fill the event.menu.menuItems to build the menu

onOpenMenuEvent

Trigger

This event will be triggered after a menu is opened and all menu items are loaded. This event hook can be used to enable / disable or show / hide menu items according to specific conditions.

Parameter

Same as onBuildMenuEvent

Parameter example

onopenmenu.png

Annotation

  • Using event.viewname to determine from which view the event is fired
  • Using event.resourceName to determine resource type name (including virtual type name)
  • event.parameter is an instance of the context resource, from which the event is fired
  • event.menu is an instance of the menu (of type ActionMenuComponent), you can manipulate the event.menu.menuItems array to enable / disable or show / hide menu items
  • Set event.menu.isLoading to true if you want to do some operations and temporarily disable the whole menu

onMenuEvent

This event will be triggered after a menu item is clicked. This event hook can be used to define the handler for the click action.

Parameter

Same as onBuildMenuEvent

Parameter example

onmenuevent.png

Annotation

  • Using event.viewname to determine from which view the event is fired
  • Using event.resourceName to determine resource type name (including virtual type name)
  • event.parameter is an instance of the context resource, from which the event is fired
  • event.menu is not needed