01-18-2012 10:01 AM
I'm an old hand at LabVIEW, but I have never used LabVIEW menus.
Here's what I ( and my customer) want to do:
Imagine a TAB control, with Page 1, Page 2, Page 3.
On page 1 is a chart, with maybe some blank space.
On page 2 is a set of channel selectors (ring ctls), numeric indicators, and string indicators, with blank space.
On page 3 is a set of channel selectors (ring ctls), and a set of slider numeric indicators.
For space reasons, I want to hide the tabs themselves. I want to right-click on the page that is showing, and have a menu offering "Show Chart", "Show Text", and "Show Sliders". These operations would simply switch tabs to show this page or that page.
The thing is, I want to append (or maybe prepend) this to any menu that pops up already.
In other words, if they click on the chart, I want to offer the usual chart operations (clear chart, SWEEP mode, etc), IN ADDITION to my custom operations.
But if they click in the blank space, the menu would have just my custom operations.
Here's a JING showing a simplified version (the real thing will have many of these and be way more crowded, that's why I want to hide tabs).
http://screencast.com/t/qIjbTVbG
The TIME indicator updates on every MOUSE DOWN? event in the tab control, proving that this is one place it could be done (in spite of the HELP declaring that "Clusters are the only container objects for which you can generate events").
How far-fetched is this idea? Ony other ideas on how to switch tabs with the tabs hidden?
Blog for (mostly LabVIEW) programmers: Tips And Tricks
Solved! Go to Solution.
01-18-2012 01:04 PM - edited 01-18-2012 01:04 PM
Hi Steve,
Have you considered using a custom run-time menu? I have attached a quick example of using a custom menu to switch between the tabs on a control using an event structure with a Menu Selection event.
I have attached the VI and the custom menu. Hopefully that helps!
Regards,
01-18-2012 01:30 PM
Yeah, but that requires a menu bar. None of the other windows in this project have one, so that would be out of place, and we're looking at saving space, particularly vertical space, as this window is intended for a 1920x1080 display, so pulling 50 pixels out of the vertical dimension is the wrong way to go.
I'm looking at showing the tabs on the SIDE of a tab control, rather than the top, but that wastes space too, so that's why I was looking at the pop-up menu idea.
(There wlil be 6, or maybe 9, of these tabs on the screen)
Blog for (mostly LabVIEW) programmers: Tips And Tricks
01-18-2012 01:58 PM - edited 01-18-2012 02:02 PM
Your idea sounds do-able.
For any FP object that you want to extend, you would create a "Shortcut Menu Activation?" Event. Within the event, you can retrieve a MenuRef.
Using the Menu Palette, you use the Insert Menu Items function, each item has a displayed name and a tag.
You then add a Shortcut Menu Selection (User) Event for the FP object to handle the selection made by the user. The ItemTags that you assign in the are available to use as a case selector. Your example would simply set the Tab control's index value to switch to the panel you want.
I built a fancy tree control (as an XControl) a few years ago for an internal tool that presented a view of files on disk and the right-click menu was context sensitive the the extension of the filename selected. Look in the Facade and the FileView Set Context Menu.vi for the guts of what I did.
I always deleted the tree menu choices and then added my own. If you don't delete the items, then your options are appended to the end.
I've attached the files here as a ZIP. (LV8.6)
01-18-2012 02:16 PM
For any FP object that you want to extend, you would create a "Shortcut Menu Activation?" Event. Within the event, you can retrieve a MenuRef.
OK, so THAT's what I was missing. I saw the examples dealing with adding menu items, but they all start on a menu bar. I didn't see how to get a reference to the shortcut menu - it's not available anywhere except within this event, apparently.
And that means I have to have an event case for each chart, each channel selector, each value indicator, each units string, and each slider.
The plan is for 12 overall tabs, each with 6 areas, each area with one chart (page 1) , 20 chan selectors + 20 value indicators + 20 units indicators (page 2), and 10 chan selectors + 10 units indicators + 10 sliders (page 3).
That's 91 items in each area, 546 items on each major tab, and 6552 items overall.
Isn't an EVENT structure with 6500+ event cases going to choke LaVIEW?
I'd have to resort to scripting just to code the dang thing.
But... how do I handle the blank-space case? If they right-click outside one of the controls/indicators, I still want to display a menu.
The MOUSE DOWN? event gives me a hook, as it happens whether you click on an item within the tab, or not, but I don't see a way to bring up the menu, or attach to the existing one.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
01-18-2012 03:21 PM
I don't have a hard solution for you, but there are a few things to play with:
Hope this helps. I don't currently have time to do more.
01-19-2012 02:31 AM
If I understand you correctly, then all you need is something like this:
This registers both the activation and selection events for all the controls and handles them in a single case.
There's a boolean in the background of each page which is used to capture those events and the rest have their regular events. If you want to filter the regular options the BG boolean has, you can customize its shortcut menu manually or programmatically to remove them or filter it from the list of controls and handle it separately. You have to make sure those booleans fill the page if you resize it, but you can do that in code easily enough.
01-19-2012 07:54 AM
THAT seems like a clear, elegant solution !
A background, invisible (or perhaps decorative) boolean catches all clicks that don't land on something else.
Lots of things I didn't realize, because I've never worked with menus:
1... a boolean can have a shortcut menu.
2... the MenuRef is available within the event case.
3... I can deal with the menu dynamically (as the click happens), rather than staticly.
Kudos to you, sir!
Blog for (mostly LabVIEW) programmers: Tips And Tricks
01-19-2012 10:22 AM
Don't forget to accept tst's answer as the solution.
01-19-2012 11:33 AM
If it indeed solves the issue, I certainly will. I need to implement it first.
Blog for (mostly LabVIEW) programmers: Tips And Tricks