Part 3: Executing Shortcut Menu Plug-Ins

Use VI scripting to define actions that LabVIEW performs when you select a custom item from the shortcut menu.

Note Note  Generate the files you need to create a shortcut menu plug-in by running the following utility VI: labview\resource\plugins\PopupMenus\Create Shortcut Menu Plug-In From Template.vi
  1. Open the plug-in execution VI (Execute x.vi, where x is the name of the plug-in) that the utility VI generates.
  2. On the block diagram, use VI scripting to modify the behavior of objects the plug-in affects. Add a Property Node or Invoke Node to access and modify the properties and methods of objects using a VI Server reference.
  3. (Optional) Add additional VIs to the LLB of the shortcut menu plug-in as needed to modify the behavior of the objects.
    Note Note  To avoid name conflicts, National Instruments recommends prefixing the filename of any additional VIs and subVIs with the name of the plug-in or using a project library. For example, name subVIs as x_subVI.vi or save additional VIs and subVIs in the project library x.lvlib, where x is the name of the plug-in.
  4. Select File»Save to save changes. Restart LabVIEW for changes to take effect.
    Tip Tip  To reload plug-ins without restarting LabVIEW, create an empty VI, add the Invoke Node to the block diagram, configure the Invoke Node for the Menus:Refresh method, and run the VI. This method is also useful if you write an installer for your plug-ins. You can run the method as part of the installation process. If you use the JKI VI Package Manager (VIPM) software to distribute your plug-ins, add the Menus:Refresh method to the post-installation VI.

Protecting Transactions When LabVIEW Executes Shortcut Menu Plug-Ins

To protect VI scripting operations when the plug-in execution VI runs, LabVIEW calls the Set Busy VI to disable the mouse. After the plug-in execution VI runs, LabVIEW calls the Unset Busy VI to enable the mouse.

You can instruct LabVIEW to automatically wrap your scripting operations in an undoable transaction by using the Transaction Control? of the build VI (x.vi, where x is the name of the plug-in). Alternatively, you can instruct LabVIEW not to control transactions in the build VI so that you manage your own transactions in the plug-in execution VI. If LabVIEW automatically creates the transaction, configure the Fail Transaction? output of the plug-in execution VI to return TRUE if this VI does not run successfully.

Part 2: Building the Shortcut Menu Using Plug-Ins Understanding Shortcut Menu Plug-Ins

Related Information

VI Scripting

VI Server Class Hierarchy

Menus:Refresh Method

Troubleshooting Shortcut Menu Plug-Ins

Tips and Tricks for Creating Shortcut Menu Plug-Ins