Adding Functions to NX Menus


 
The following paragraphs describe adding application-independent functions to the menu bar and quick view pop-up. This section also describes adding an application-specific function to the menu bar.
 

Menu Bar Application-Independent Functions


 
There is a detailed example of adding application-independent menu items to the menu bar in the online documentation Open C MenuScript User Guide->Sample Exercises->Add Custom Buttons. This example shows how to add menu items by either using an added menu file or copying and modifying an existing menu file. To add your own custom actions, simply follow that example, replacing the actions shown in the example with those you have written in C and registered using UF_MB_add_actions.
 
You probably want to include all of your application-independent functions in a single Open C shared library and register them with a single call to UF_MB_add_actions. Since you want your functions to be available for binding when your menu file is read during NX startup, place your shared library in the same startup directory where your menu file was placed. Figure below illustrates the placement of your files into a an arbitrary directory, which we called /user_directory. You would then add the directory "/user_directory" into the file $UGII_BASE_DIR/ugii/menus/custom_dirs.dat.
 

 
Fig: Using the startup directory
 

Quick View Pop-up Application-IndependentFunctions


 
The steps in adding application-independent functions to the Quick View Pop-up menu are identical to those for adding to the menu bar in the previous example except that in the menu file EDIT statement, the name of the View Pop-up menu is specified instead of the main menu bar, e.g.:
 
VERSION 120
EDIT UG_GATEWAY_VIEW_POPUP
TOP_MENU
BUTTON my_button
LABEL my_button
ACTIONS my_action
END_OF_TOP_MENU
 
my_action is the action name you specified for one or your callbacks in the table passed to UF_MB_add_actions. You can specify additional buttons and their actions in the same manner and include all of the callbacks in a single shared library. You can locate your buttons more precisely using the BEFORE and AFTER menu file statements, or place them on new or existing cascade menus as shown in the User Guide.
 
If you are adding functions to both the main menu bar and the View Pop-up, you can define all of the callbacks in a single shared library, but you need two menu files, since the EDIT command that specifies which menu system (i.e. UG_GATEWAY_MAIN_MENUBAR or UG_GATEWAY_VIEW_POPUP) to edit can be specified only once at the beginning of the menu file. In this case the place of your files would look like this:
 

 
FIG:   View Pop-up
 

Adding An Application-Specific Function To TheMenubar


 
 The fifth example of Chapter 5 of the MenuScript User Guide illustrates making application-specific menu bar changes. To add your own custom actions to a specific application, simply follow that example, replacing the actions shown in the example with those you have written in C and registered using UF_MB_add_actions.
 
In this case, you need to edit the application button definition to specify on the LIBRARIES statement, your shared library to be loaded the first time you enter the application, and to specify on the MENU_FILES statement your menu file to be loaded the first time you enter the application, e.g. create a menu file my_modeling_app.men
 
VERSION 120
BEFORE UG_APP_DRAFTING
APPLICATION BUTTON UG_MODELING
LABEL Modeling...
LIBRARIES my_modeling.sl
MENU_FILES/APPEND my_modeling.men
 
The menu file my_modeling.men and the shared library my_modeling.sl must be placed in the application subdirectory so that loading them is deferred until the first time you enter the Modeling application. However, menu file, my_modeling_app.men shown above must be placed in the startup subdirectory, so that your library and menu file information is attached to the Modeling button when NX is started and can be used to load your files when you first enter the Modeling application. The placement of your files for this example should be:
 

 
Fig: Adding to the Menubar