I have a panel with several indicators and controls and I want to be able to provide users with the same set of right click options for each of these irrespective of enabled/ disabled state. It appears that disabled controls don't trigger the Shortcut Menu Activation? event but they do trigger the Mouse Up and Mouse Down events. While I can roll my own menu and drive my menu population and placement off of the greference and coords contained in the Mouse Up/ Down event data, I'd much prefer to just use the native context menu.
Is there a way to get a reference to a GObject's context menu? Is there some other way to do this or am I just going to have to bite the bullet?
Solved! Go to Solution.
Is there some other way to do this or am I just going to have to bite the bullet?
One useful trick is using filter events - in this case the Mouse Down? event. Because they have the filter option, their code is executed before other events, so you can use the event and if the click was a right click on a disabled control, enable the control and then set it up so that the control is returned to its original state after the filter event is done and the right click was performed on an enabled control.
Very clever solution, tst! Thanks for posting this. I think this very well may work. The only concern I have here is that this introduces a small (infinitesimally so?) chance of an unauthorized control click though this should be easy for me to test.
I've not seen the CtlRef property node before--how did you go about creating that? It looks like you simply created a CtlRef control? I can verify that this works, just curious what's happening here. In particular, how does value signaling this trigger the Shortcut Menu Activated? event?
This is essentially the same thing as what tst posted, but maybe a little more detailed.
I've not seen the CtlRef property node before--how did you go about creating that? It looks like you simply created a CtlRef control?
Yes, I just created an indicator from the event terminal and then create a property node for the indicator.
In particular, how does value signaling this trigger the Shortcut Menu Activated? event?
It doesn't. The event is triggered because the control is enabled and you right clicked it.
The property was meant to show a crude way to handle the second part - disable the control after the first event was completed and the menu appears. Doing it this way would allow you to handle multiple controls with the same event, because it gets the reference of which control to enable, but if the VI was more complicated, I might decide to use a different mechanism.