The TestStand VIs and functions palette contains the following VIs for creating and handling menu items that execute TestStand UI Control commands:

  • TestStand - Insert Commands in Menu
  • TestStand - Cleanup Menus
  • TestStand - Remove Commands From Menus
  • TestStand - Execute Menu Command

Because maintaining the current state of the menu bar can be difficult, NI recommends that you handle the menu bar only when required. The Event structure in a main event loop can include a case to handle the Menu Activation? event to determine when you open a menu or select a shortcut key that might be linked to a menu item. The block diagram that handles this event can then rebuild the menu bar.

The Full UI - Top-Level VI in the example user interfaces shows how to rebuild the menu bar. The Menu Activation? case in the main event loop of the VI determines which control has focus, if the control is a TestStand User Interface (UI) Control, and calls the Full UI - Rebuild Menu Bar VI to rebuild the menu bar. When you click the menu bar, LabVIEW does not automatically return focus to the control after handling a user menu event. The Menu Activation? case in the Full UI - Top-Level VI passes a reference for the control with focus to the Menu Selection (User) case so the application can later restore focus to the control.

You can add a Menu Selection (User) case to the Event structure in a main event loop to handle user menu selections but limit the tasks you perform in the Menu Selection (User) case to ensure that LabVIEW handles the menu selection in a timely manner. When the case performs ActiveX operations that can process messages or performs TestStand operations that can call back into LabVIEW, the application must perform these operations in a LabVIEW execution system other than user interface, such as standard or other 2.

The Full UI - Top-Level VI in the example user interfaces shows how to process user menu events. The VI uses the standard LabVIEW execution system. The Menu Selection (User) case in the main event loop calls the Full UI - Add To Menu Queue VI to queue the operation for processing the menu outside of the main event loop. The Full UI - Process Menu Queue VI waits for and processes queued operations. For TestStand menu items, the Full UI - Process Menu Queue VI calls the TestStand - Execute Menu Command VI to execute the appropriate TestStand command. For non-TestStand menu items, the VI calls the Full UI - Process User Menus VI, which you can customize to handle user menu selections.

The LabVIEW application menu items for copy, cut, and paste operate on LabVIEW controls only and do not operate on TestStand UI Controls. In addition, the TestStand menu commands operate on TestStand UI Controls only and not on LabVIEW controls. When you rebuild a LabVIEW menu in the Menu Activation? event case and you call the TestStand - Insert Commands in Menu VI to insert CommandKind_Edit_Copy, CommandKind_Edit_Cut, or CommandKind_Edit_Paste, pass False to the TestStand UI Control Has Focus control and "Edit" to the Top-Level Menu to Insert Into control to insert the corresponding LabVIEW application menu items instead of the TestStand menu command.