Stacked Control Shortcut Menus Said YES!
Don't you love it when you make an elaborated guess on an implicit/undocumented/hidden feature and it turns out you guessed right? It feels good for the ego, and feels good to discover simple things in LabVIEW, after several years of extensive use in my case. So I thought I'd share my momentary joy and pride (even though the feature seems obvious for some reader - sorry!)
The truth is, the title says it all. I wanted to add a bunch of shortcut menu items to a pane/panel, no matter where the user would click. Of course this pane contains a few controls, and there comes a tenacious doubt: how will LabVIEW handle the shortcut menus when I right-click one of the pane controls?
As you can imagine, LabVIEW saves you some time and pain here. The pane shortcut menu can be stacked with the frontmost right-clicked item. Or more exactly, the right-clicked control shortcut menu items are conserved as the pane Shortcut Menu Activation event triggers.
Right, one slightly annoying thing is that you cannot attach a *.rtm file (LabVIEW run-time menu file) to a pane like you could with a control (through the Advanced -> Shortcut Menu -> Edit... menu) or a VI. So you don't have a choice, you have to use the Shortcut Menu Activation and Shortcut Menu Selection events on the pane. You can add your custom pane menu items in there using the Insert Menu Items function. If the user right-clicked a control, the menu reference already contains this control shortcut menu. Interestingly enough, you can also get a reference to the right-clicked control if there's any, using the SubObj event data node. What for? In this example, I simply add a separator before the pane menu items if I right-clicked a control, so we can easily tell which menu item belongs to which menu.
There goes your menu! Dynamic, stackable, flexible, revealing all the features the user needs.
When dealing with the Shortcut Menu Activation event, the menu reference is only valid until the event case is done executing. Don't try to pass this menu reference to some parallel process or store it in a shift register or in a variable for a later use, the reference will be invalid.