View on GitHub

Insert-LVClass-Property-Node

LabVIEW shortcut menu plug-In to insert LVClass Property Node

layout: page title: “LabVIEW Shortcut Menu Plug-ins” permalink: /lvmenus/

LabVIEW Shortcut Menu Plug-ins

With LabVIEW 2015 came the ability to add custom items to the shortcut menu (aka right-click menu)of front panel and block diagram objects with G code. This allows you you to pimp your LabVIEW editor by adding new menu items, rearranging or replacing existing menu items and manipulating menu items (enable/disable, check/uncheck, …).

The LabVIEW Shortcut Menus are accessible from front-panels and block-diagrams at Edit-Time and only from block-diagrams at Run-Time. At Run-Time, front-panel shortcut menu use another technology you may already known as Runt-Time Menu (.rtm files).

How it works?

At startup, LabVIEW searches and loads LabVIEW Shortcut Plug-ins from LLBs from some specific locations. You have 2 kinds of plug-in folders:

If two plug-ins have the same name, LabVIEW will give the priority to the plug-in in the \resource\plugins\PopupMenus directory and won't execute the other.

The anatomy of a LabVIEW Shortcut Plug-in

A Shortcut Menu Plug-in contains 3 main and mandatory components:

The Shortcut Menu Plug-in has to be saved in an LLB in oder to be loaded by LabVIEW at launch. LLBs allow fast VI hierarchy loading and an easy distribution with a single file.

You can place helpful VIs into the LLB or into a subdirectory (ignored by LabVIEW when searching plug-ins).

Create your own LabVIEW Shortcut Menu Plug-In

Where to start?

When you create a Shortcut Menu plug-in, you will go through 3 steps:

LabVIEW offers an utility to guide us creating new Shortcut Menu plug-ins. Open the \resource\plugins\PopupMenus\Create Shortcut Menu Plug-In From Template.vi and fill the different fields and run the VI.

Create LabVIEW Shortcut Plug-In From Template

You have to enter the name of your plug-in, specify whether the shortcut menu plug-in affects edit time or run-time shortcut menus, and optionnaly check/uncheck Open Plugin VIs after creation, before running the VI.

This utility generates the LLB, with the 3 main components of a Shortcut Menu plug-in, correctly named and to the proper folder.

Let’s use a real-life scenario as an example of the LabVIEW Shortcut Menu plug-in creation process. Imagine we want to implement a Shortcut Menu plug-in, called myPlugIn, that will change the background color of Numeric controls and Numeric constants.

Affected Items

First we specify which front-panel or block-diagram objects our shortcut menu plug-in operates on by editing the Affected Items control.

Affected Items

This Typedef contains a cluster of VI Server Refnum Arrays that represents the selected objects of that type. You can add an object by adding an array of a refnum type, remove an object by deleting an array, or choose a different object by right-clicking an array » “Select VI Server Class” and selecting the refnum type you want under the Generic hierarchy.

To meet our myPlugIn requirements, the Affected Items should have 2 arrays, one for the Numeric Control objects and one for the Numeric Constant objects. Then, we have the following Typedef:

Affected Items myPlugIn

Based on the object types defined in the Affected Items, LabVIEW runs a specific set of VIs on a given right-click. In our case, our Builder VI will be called on a right click on front-panel numeric controls and on block-diagram numeric constants.

:bulb: Note

Builder VI

Now, we have to tell LabVIEW which items to add to, or toggle, or remove from the shortcut menu.

Builder VI

In the Builder VI each menu item is described by :

You get information about the user selection with the VI inputs:

You can implement some logics based on the user selection information to tell LabVIEW which shortcut menu items to add to the menu.

Back to our example, using the following rules:

Builder VI myPlugIn

:warning: Caution

:bulb: Note

Execute VI

Let’s dive into the final step and define actions that LabVIEW performs when you select a custom item from the shortcut menu.

Execute VI

As discussed above, LabVIEW loads context menu plug-ins on startup, so you have restart LabVIEW for the changes to take effect and see your your Shortcut Menu Plug-In.

:warning: Caution

:bulb: Note