LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to programmatically set shortcut menu without Event Structure

Hey guys,

 

I have this application where I would have to change the shortcut menu of multiple controls dynamically.

Specifically, I am thinking about loading the shortcut menu info from a file, and altering the shortcut menu

 of several controls of a VI at the start.

 

-I know you can use event structure to get the MenuRef of a certain control, but is it possible to get this

without using an event structure?

 

-Since I have a lot of controls to change, even if I have to use an event structure, is there an efficient way of

changing shorcut menu like you can with property node? (eg: get reference with Controls[] and using For Loop to set all necessary properties)

 

Thanks

0 Kudos
Message 1 of 3
(2,810 Views)

Just as a clarification, I am talking about the runtime shortcut menu, like when you right click a control,

it would display: Properties, Reset to Default Values,etc..

0 Kudos
Message 2 of 3
(2,808 Views)

Here's a way to do it, but it's a bit kludgey:

Do this for each control that will have changing menus.

1. Right-click the control, select Advanced -> Runtime Shortcut Menu -> Edit ...

2. Create a set of .rtm files with the different custom menus (give them crazy names like "Ctl_A Menu_1.rtm", "Ctl_A Menu_2.rtm").

3. Using the same process, create one more .rtm file with anything for the menu (Name it something like "Ctl_A Menu.rtm").  When you exit the menu editor, be sure to answer "Yes" when it asks if you want to change the run-time menu.  Now the runtime menu for that control will be linked to that file.

4. To programatically change the runtime menu for that control, before the VI is loaded, copy one of the custom menus (e.g. "Ctl_A Menu_1.rtm") over the linked menu file ("Ctl_A Menu.rtm"), then load and run the VI

Here's what that code could look like:

.Captured001.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 3 of 3
(2,771 Views)