LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to nest Menu Ring control

I have a menu ring that when I select a menu item I need to select a sub list of items.

 

How can this be done?

 

i.e. Item2 has additional items to choose:

 

Menu Ring

Item1

Item2

Item3

Item4

 

 

Item2 Menu

ItemA

ItemB

ItemC

0 Kudos
Message 1 of 11
(5,205 Views)

Hi NI Nubie,

 

If you wanted to do it all in one Menu Ring, you could dynamically repopulate the list items to display the sub options.  Not very graceful, as you end up hardcoding the menu items, but it just might do the job.

 

I've attached a quick example I've knocked up to show you.

 

 

Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)

Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor

0 Kudos
Message 2 of 11
(5,032 Views)

Charlie showed a neat way of doing it, but if you would rather design your menu ring using the UI Editor, you can create a second ring for your Item2 submenu, and edit the control to be Initially Hidden.  In your main() function, before you display the panel, move the submenu to the same location as the main menu.  You could do this in the UI editor as well, but then you would have to move one to get to the other, and someone else working on your project may not know that there are two controls on top of each other.

 

In your callback for the main menu, if item 2 is selected, make the main menu invisible and make the submenu visible.  In your submenu, include a menu option to Return to main menu.  In the submenu callback, if the Return item is selected, make the submenu invisible and make the main menu visible.

 

I have attached a sample project doing that.

Message Edited by Al S on 09-09-2009 12:36 PM
0 Kudos
Message 3 of 11
(5,020 Views)

A better solution to this question in my opinion is showing a real menu bar (which can hold several nesting levels, if needed) with RunPopupMenu: the menu bar can be loaded at runtime without need for it to be shown on the panel; RunPopupMenu dynamically displays it where the user clicks; the return code from the function can be tested against menu item constants to detect which element the user has selected.

Look at the attached example.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 11
(4,994 Views)

Roberto,

 

Great idea, using the menu bar popup!

 

I've taken this and adapted my example to store the mouse x,y on left click and call the pop-up when Item 2 is selected.

Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)

Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor

0 Kudos
Message 5 of 11
(4,982 Views)

Updated, as I'd posted my development code Smiley Surprised

 

 

Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)

Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor

0 Kudos
Message 6 of 11
(4,978 Views)

Updated:

 

  • now updates the Ring text/value with the selection from the Menu Bar popup
  • reverts to previous selection if the popup loses focus
  • code comments
  • executable in zip

Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)

Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor

0 Kudos
Message 7 of 11
(4,960 Views)

Here is another example using a menubar with sub menus and the ring control. Hopefully it is helpful.

 

0 Kudos
Message 8 of 11
(4,884 Views)

Hi Roberto.

 

I like your solution and will use it in the future but for this particulat menu ring I need to display the selction after it is made.

 

The menu rung displays test selections and then displays the selection while the test runs.

There are 32 selections with one selection requiring the sub-selection feature.

 

Thanks.

0 Kudos
Message 9 of 11
(4,878 Views)

Hi Roberto.

 

On second thought I could put a text control item beside the button and just copy the selected test message to the text control item.

0 Kudos
Message 10 of 11
(4,876 Views)