NXKnowledge

NX Open Programmer's Guide > Execution Methods > Programs, Journals, or Callbacks from New Menu Items > Executing Callbacks (Menu Event Handlers)

Executing Callbacks (Menu Event Handlers)

Callbacks are tied to menu buttons using the same ACTIONS command used for journals and programs. However, the menu file does not reference the callback's name directly — it references a string that must be registered to the callback.

Callbacks are registered with their associated strings in a custom application via:

  • AddMenuAction (C++, VB, or C#)
  • addMenuAction (Java)
  • UF_MB_add_actions (Open C)

See the language-specific topics (Callback Registration for NX Open for C++ / .NET / Java) for details.

Examples

All examples register two callbacks, "my_app_hello" and "my_app_goodbye", in different places in the NX menu. Place the sample menu file in the startup directory, then register the callbacks with NX in your preferred language.

Example 1 — Adding Menu Items to the Tools Menu

VERSION 120
EDIT UG_GATEWAY_MAIN_MENUBAR
MENU UG_TOOLBOX
    BUTTON MY_ITEM1
    LABEL Hello
    ACTIONS my_app_hello
    BUTTON MY_ITEM2
    LABEL Goodbye
    ACTIONS my_app_goodbye
END_OF_MENU

To find the unique text string NX uses for an existing menu (e.g. UG_TOOLBOX), find the label displayed in NX (e.g. "Tools" — the underlined letter indicates an & prefix in the menu file), then search .men files under %UGII_BASE_DIR%/ugii/menus for LABEL &Tools — this resolves to ug_main.men. Similarly, "Part History..." (Menu → Information → Part → Part History...) resolves to button UG_INFO_PART_HISTORY in ug_main.men.

Example 2 — Adding a New Menu Pull-down

VERSION 120
EDIT UG_GATEWAY_MAIN_MENUBAR
MENU MY_MENU
    BUTTON MY_ITEM1
    LABEL Hello
    ACTIONS my_app_hello
    BUTTON MY_ITEM2
    LABEL Goodbye
    ACTIONS my_app_goodbye
END_OF_MENU
TOP_MENU
    CASCADE_BUTTON MY_MENU
    LABEL My App
END_OF_TOP_MENU

Example 3 — Adding a New Pull-down to an Existing Menu

VERSION 120
EDIT UG_GATEWAY_MAIN_MENUBAR
MENU MY_MENU
    BUTTON MY_ITEM1
    LABEL Hello
    ACTIONS my_app_hello
    BUTTON MY_ITEM2
    LABEL Goodbye
    ACTIONS my_app_goodbye
END_OF_MENU
MENU UG_TOOLBOX
    CASCADE_BUTTON MY_MENU
    LABEL My App
END_OF_MENU

Example 4 — Positioning New Menu Items within an Existing Menu

Use BEFORE/AFTER in place of MENU to position items precisely, e.g. adding a pull-down to the File menu just after File tab → Utilities:

VERSION 120
EDIT UG_GATEWAY_MAIN_MENUBAR
MENU MY_MENU
    BUTTON MY_ITEM1
    LABEL Hello
    ACTIONS my_app_hello
    BUTTON MY_ITEM2
    LABEL Goodbye
    ACTIONS my_app_goodbye
END_OF_MENU
AFTER UG_FILE_UTILITIES_MENU
    CASCADE_BUTTON MY_MENU
    LABEL My App
END_OF_AFTER

Related Topics

  • Programs, Journals, or Callbacks from New Menu Items — Overview
  • Introduction to Menu Files
  • Executing Programs
  • Executing Journals
  • Callback Registration for NX Open for C++
  • Callback Registration for NX Open for .NET
  • Callback Registration for NX Open for Java

Source: https://docs.sw.siemens.com/en-US/doc/209349590/PL20220512394070742.nxopen_prog_guide/new_menu_executing_callbacks · retrieved Tue Jul 07 2026 00:00:00 GMT+0000 (Coordinated Universal Time)