LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

run-time shortcut menu odd behaviour

I have created a run-time shortcut menu that has two top level menu's (Add Facility and Remove Facility) and each sub-menu has the same identical list of Item Names (see attached VI).

 

Now when I run the VI and select an item from the Add Facility top menu the ItemPath value returns "Add Facility:Item Name" - all OK.

 

However when I select an item from the Remove Facility top menu instead of returning "Remove Facility:Item Name" it returns "Add Facility:Item Name" as above.

 

I can fix this if I create different Tag names for the Remove Facility sub-menu items, but surely LabVIEW should return the correct ItemPath regardless if the sub-menu item names are identical?

 

Chris

0 Kudos
Message 1 of 15
(3,172 Views)

Don't see what you reported. Each path is returned as it should. 

 

In terms of tags, each item in the menu will have a unique tag. If you try to assign duplicate tags, LV will automatically append a number to make them unique.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 15
(3,166 Views)

Well that's odd.

 

If I right-click and select ADD Facility -> Work Order Closed then the ItemPath value returned is ADD Facility:Work Order Closed.

 

Now if I right-click and select REMOVE Facility -> Work Order Closed then the ItemPath STILL returns ADD Facility:Work Order Closed!!

 

In fact anytime I select an Item in the REMOVE Facility menu the ItemPath is ALWAYS returned as ADD Facility.

 

I'm running LabVIEW 2010 if that's any help.

 

Chris

0 Kudos
Message 3 of 15
(3,159 Views)

It seems like the menu bar at the top of the application appends _1 for duplicate items like Mike says.  But it doesn't seem to do that for shortcut menus. I don't know why not.  Is this a bug?

 

As a result, the event structure finds the first menu tag that matches rather than the one you actually picked.

 

What you can do is use the string array for both to wire into the item names.  But create your own array of unique item tags to wire into the item tags input.  Then it seems to grab the correct one.

 

See Attached.

0 Kudos
Message 4 of 15
(3,153 Views)

Yeah that's what I eventually did as well (ie. create unique TAGS for one of the sub-menu's).

 

But as you suggested this seems like a bug to me, since you should be able to have identical sub-menus for two (or more) different Top Menu's.

 

Thanks anyway.

 

Chris

0 Kudos
Message 5 of 15
(3,151 Views)

If you try to add a shortcut menu on the front panel object, by right clicking on it and going through 'Advanced..Run-Time Shortcut Menu..Edit' and add a custom menu, then the item tag is automatically updated with '_1' as soon as you add an Item Name that is already added once.

 

Since you are creating a custom menu programatically, this handling of tags is missed out.

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 6 of 15
(3,144 Views)

But here is an interesting variation on that.  http://forums.ni.com/t5/LabVIEW/menu-path/m-p/1919241#M642671

 

It has a custom run-time menu.  You can programmatically add items to the menu as a part of the application.  However it still automatically appends a _1 to the tags for the second menu.

0 Kudos
Message 7 of 15
(3,134 Views)

Nice link Ravens.

It explains why we need unique TAGS, but then what's the point of the ItemPath variable if not to uniquely identify a Menu/Sub Menu combination, so that we don't have to worry about having unique ItemNames in Sub-menus.

 

Chris

0 Kudos
Message 8 of 15
(3,103 Views)

Hi Chris,

 

as explained in the linked thread: the item tag is all that is relevant for the menu item. The tag has to be unique!

 

The item path is just additional information for the programmer. Usually it isn't needed as you already have the unique item tag...

 

So you in the first use duplicate tags and then in the second you complain about LabVIEW not finding the correct item path for your duplicate tags? Think about it...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 15
(3,096 Views)

Hi GerdW,

No I understand (now) the need for unique tags, but I'm just saying it would make life a little easier and would seem more logical for LabVIEW to parse this information correctly into the ItemPath value for multi-layer menus then we wouldn't have to worry about the issue of having identical sub-menu's.

 

Chris

0 Kudos
Message 10 of 15
(3,091 Views)