You are on page 1of 5

Create Custom Run-Time Shortcut Menus for LabVIEW Front Panel Objects

Publish Date: Oct 02, 2015

Overview
While LabVIEW provides hundreds of front panel controls for developing a professional user interface, there are often situations in
which you need to customize the behavior of these controls. With LabVIEW 8 and later, you can create your own run-time shortcut
menus for front panel objects. This gives users more control over the behavior of your application and creates a more professional
interface for your users. In this tutorial, we will describe the process of creating a custom run-time shortcut menu for a native
LabVIEW graph. To demonstrate this, we will create a new run-time shortcut menu item which enables the user to export an image
of the graph to a Microsoft Excel spreadsheet directly from the graph's run-time shortcut menu.

1. Customizing the Run-Time Shortcut Menu

The first step in developing our run-time shortcut menu is to define the list of items in that menu. In our example, we are defining
the shortcut menu of a graph. To do this, first place a stop button and a waveform graph on the front panel. Then, use the shortcut
menu for that graph to select Advanced>>Run-Time Shortcut Menu>>Edit... as demonstrated here:

Note Controls or indicators with customized run-time shortcut menus that you add into an array shell use the shortcut menu
of the array.

Once this item is selected, LabVIEW will launch the Menu Editor. From this window, we select all of the items which will exist in the
run-time shortcut menu. Because we are creating a new run-time menu, we select Custom from the Menu Type pull-down menu
of the dialog box:

Now we are able to define the items that exist within our run-time menu. In this example, we will use one preexisting menu item,
Clear Graph, and one new item which we will create, Export to Word. Let us start with the new item. To create our own custom

item with the Menu Editor, select User Item from the Item Type menu. We must designate the Properties for this item. First, we
1/5 www.ni.com
item with the Menu Editor, select User Item from the Item Type menu. We must designate the Properties for this item. First, we
create the Item Name which is the name displayed in the run-time shortcut menu. When we type in the Item Name, the same text
automatically appears in the Item Tag field. You can modify the tag name to give the shortcut menu item a unique identifier. The
block diagram uses the tag name to identify the shortcut menu item programmatically. Shortcut menu item tags can have the
same name as shortcut menu item names

Next, we want to add the Clear Graph item. Click the blue plus button on the toolbar to add a new items to the shortcut menu.
Because the Clear Graph item already exists in LabVIEW, we do not have to create it ourselves. To access a menu item that
already exist, use the Item Type menu and select Application. From this selection, you can choose the item you want to use.

The Menu Editor is now populated with the Clear Graph item. Notice that other fields in the Items Properties have automatically
been filled for you.

Note You can arrange the shortcut menu hierarchy in the dialog box by clicking the arrow buttons on the toolbar, using the
hierarchy manipulation options in the Edit menu, or by dragging and dropping. You can expand or collapse hierarchies by
clicking the submenu glyphs or by choosing from the expand or collapse options in the Edit menu. To add separators, select

2/5 www.ni.com
Separator in the Item Type pull-down menu

We have now created both items for our run-time shortcut menu. Select FileSave. In the dialog box that appears, select Save
with Control. This saves the run-time shortcut menu with this particular control and prevents us from having to keep up with
another file. If you select Save to file, you can save the shortcut menu to a place on disk. Using this method, you could apply the
same shortcut menu to another control in the future and not have to create it over again. When you load the VI, the customized
shortcut menu automatically loads with the appropriate control but you must make sure that you have access to the file.
2. Handling Run-Time Shortcut Menu Selections

After you have defined the items for your run-time shortcut menu, you must configure an Event structure to handle each menu
item that you created in the custom menu. Therefore, we will use an Event Structure to handle the Export to Word menu item that
we created.

Place an Event structure on the block diagram inside of a While Loop. For this example, use the timeout event case to plot random
data, from the Simulate Signal Express VI, onto our graph and wire a constant of 50 into the timeout event. Next, create an event
case to stop our application by monitoring the Value Change event for the stop button. Both of these event cases are shown here:

Next, right-click the Event structure and Add Event Case from the shortcut menu. In the Edit Events dialog box, select Waveform
Graph (the graph on our front panel) from the Event Sources list and select Shortcut Menu Selection (User) from the Events list.
LabVIEW triggers this event when the user makes a selection on the run-time menu.

Click the OK button to close the dialog box. Now place a Case structure inside the Shortcut Menu Selection (User) case of the
Event structure. We will use this case structure to determine which menu item was selected and then handle that particular item.
3/5 www.ni.com
Event structure. We will use this case structure to determine which menu item was selected and then handle that particular item.
Wire the Item Tag event data field to the selector terminal on the border of the Case structure and enter the tag name of the menu
item (Export to Word) in the case selector label.

Now we just write the LabVIEW code which exports an image of the graph into a Microsoft Word document. To do this, first create
an invoke node for the waveform graph and call the Export Image method. This method creates a simplified image of a graph and
is very useful for creating reports. Specifically, it modifies the colors of the image so that they will show up properly in other
documents.

Use this method to save an image of the graph to file and then use the New Report and Append Image to Report VIs (requires
the Report Generation Toolkit for Microsoft Office) to create a report and append this image into it.

Our application is now ready to run. Switch to the Front Panel and run the VI. Once it is running, access the run-time shortcut
menu and notice it is what we created.

Select the Export to Word menu item. Microsoft Word will launch a document and import a simplified image of this graph into the
document.

4/5 www.ni.com
In this tutorial, we created a custom run-time short menu for a waveform graph. There are many other ways to create customized,
professional user interfaces with LabVIEW. To learn more about customizing the LabVIEW user interface, see the other tutorials
and example programs listed below.
Related Links:
Animating LabVIEW Controls

Customer Reviews

1 Review | Submit your review

5/5 www.ni.com

You might also like