LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

No menu on double-click with the right button

If anyone can help me out here....

 

I want to implement the following:

 

User makes a double-click with the right mouse button on a control and a specific action is carried out.  Fine, I know how to do this.

BUT: If the user only clicks once, I want (After a delay to allow for a double-click) the shortcut menu to appear.

 

Anyone know how to do this?

 

Problem is that the "Shortcut Menu Activation?" filter method blocks the UI and the second mouse click cannot be registered.  We need to stay within this event because only here is the shortcut menu refnum valid for dynamic population.

 

Shane.

0 Kudos
Message 1 of 27
(4,605 Views)

Maybe use shift + right-click, or ctrl+shift+right-click instead of double right-click ?

 

George Zou
0 Kudos
Message 2 of 27
(4,580 Views)

Nope, the requirement is a plain old right click.....

 

Not my code, it's an external requirement.

 

Personally, I am inclined to say it'sa ctually impossible with LV but if anyone has an idea....? Virtual Beer on offer....Smiley Happy

 

Shane.

0 Kudos
Message 3 of 27
(4,577 Views)

Disable the popup menu, then you can catch both right-click and right-double-click events.

Create your own "menu" instead of the popup menu.

 

George Zou
0 Kudos
Message 4 of 27
(4,563 Views)
The only thing I can think of is having the Mouse Down? event before the activation event (which I believe should get it to process first) and discarding the event so that the menu activation doesn't happen. Then, if the second Mouse Down? doesn't happen (i.e. a timeout), simulate a right click event using the previous coordinates (e.g. using send_input) and this time don't discard it. This should trigger the activation event. This seems way too flimsy, but I think it should work. The other option, of course, is to build your own context menu system, but I believe you would prefer to avoid that. I think I still have some code which does this using VI server and reentrant VIs, if you want me to dig it up.

___________________
Try to take over the world!
Message 5 of 27
(4,562 Views)

@tst wrote:
The only thing I can think of is having the Mouse Down? event before the activation event (which I believe should get it to process first) and discarding the event so that the menu activation doesn't happen. Then, if the second Mouse Down? doesn't happen (i.e. a timeout), simulate a right click event using the previous coordinates (e.g. using send_input) and this time don't discard it. This should trigger the activation event. This seems way too flimsy, but I think it should work. The other option, of course, is to build your own context menu system, but I believe you would prefer to avoid that. I think I still have some code which does this using VI server and reentrant VIs, if you want me to dig it up.

This option does seem to work.  Attached is a VI I made that does this function saved in 2011.  Double right click the stop button to see the menu, choose stop from the menu to stop.  Single left click on stop, will stop the VI.

0 Kudos
Message 6 of 27
(4,512 Views)

Hooovahh, you misunderstood the requirement. The point is to open the menu only if there was a single click. For that, you need to know that the second click didn't happen, which means you need a timeout.

 

In theory, it might be possible to use two event structures with filter events, with a wait in one of them, and use the event's Double Click modifier terminal, something along the lines of the attached example (9.0), which doesn't work. Even if it did work, I don't think I would recommend this method, as it seems even less stable than the one I suggested earlier.

 

I'm also attaching the native context menu implementation (7.0), which appears to have been uploaded once upon a time by PJM_LabVIEW. I gave it a quick run and it seems to be missing a couple of OpenG VIs, but I'm sure you can work around that if you prefer this method to the other one I suggested.


___________________
Try to take over the world!
Download All
0 Kudos
Message 7 of 27
(4,479 Views)

I was bored, so here's an implementation of the other method (2009) which does work. I still think it's a bit too flimsy, but it seems to function reasonably well. I didn't handle all kinds of things, such as setting proper times or allowing left clicks to work, but I think this demonstrates the principle adequately.


___________________
Try to take over the world!
Message 8 of 27
(4,473 Views)

Tst, thanks for the example but this isn't what I was looking for.

 

The original request was for a single right-click to open the shortcut menu after a delay.

 

A double right-click should NOT open the menu and gets handled internally as a separate user input.

 

Running multiple event structures with filter events is not workable because the filter events are blocking the UI so only one can execute at a time.  The second filter will only be activated AFTER the timeout has expired, which is not the required behaviour.  I had tried this but I was unable to get it working.

 

Shane.

0 Kudos
Message 9 of 27
(4,469 Views)

What's wrong with the mod in my last post? I believe it should work exactly as you want (with various bug fixes which need to be applied).


___________________
Try to take over the world!
0 Kudos
Message 10 of 27
(4,463 Views)