LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Run Time Right Click Menus for Disabled GObjects

Solved!
Go to solution
Highlighted

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? 

0 Kudos
Message 1 of 5
(231 Views)
Highlighted
Solution
Accepted by topic author RkTrey

@RkTrey wrote:

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.

 

For example:

 

rightclick.png


___________________
Try to take over the world!
Message 2 of 5
(206 Views)

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?

0 Kudos
Message 3 of 5
(179 Views)
Highlighted

This is essentially the same thing as what tst posted, but maybe a little more detailed.

 

Redhawk92_2-1593544372364.png

 

 

Redhawk92_3-1593544387710.png

 

Andrew
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 4 of 5
(150 Views)
Highlighted

@RkTrey wrote:

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.

 

@RkTrey wrote:

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.


___________________
Try to take over the world!
0 Kudos
Message 5 of 5
(93 Views)