LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect the pressed mouse button inside a event structure if not only the mouse starts the event?

Hello,

 

if I run a event structure with "mouse button pressed" I am able to dected if the left or right mouse button was pressed (value "Schaltfläche" = 1 or 2).

 

2016-11-11_16h09_09.png

 

But now, I want to add a second event to start the event structure. In consequence the value "Schaltfläche" is not available any longer. Is there another way to still deteced which mouse button was pressed?

 

2016-11-11_16h12_27.png

 

Thanks a lot.

Michael

 

0 Kudos
Message 1 of 6
(1,085 Views)

Hi Micha,

 

what about creating two event cases instead of merging both events into one case?

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

0 Kudos
Message 2 of 6
(1,083 Views)

Instead of adding to the events that trigger that case, you want to create a new event case.  The Event Structure can have many event cases, each handling their own event.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 3 of 6
(1,077 Views)

That is right. I could add another event case. But inside the event cases I would like to use the same code. So I have to double the code. Because of a lot of other inputs inside the code that would not so easy.

 

I would prefer to detect the mouse button inside one event case. Is there a solution?

 

Thanks.

0 Kudos
Message 4 of 6
(1,074 Views)

You won't have certain items in the Event Data Node of the event structure unless the items are common for all events. In your case, "Mouse Down" for the button and "Value Changed" for the path control do not share much in common, and that is why you lose the "Button" item.

 

You can set each control's events to "Mouse Down":

Mouse Button Event 1.png

 

If you're really needing "Mouse Down" and "Value Changed" to call same code, you can do the following:

Mouse Button Event 2.png

 

If you're just concerned as to what button is mouse pressed on any control on the front panel, add an event for the pane instead of individual controls:

Mouse Button Event 3.png

Feel free. Contact me for anything more,
    Pang

You too can be LabVIEW Awesome!
0 Kudos
Message 5 of 6
(1,059 Views)

It's more likely you'll want similar code instead of the same code.  Are you worried about which mouse button is pressed if the other option triggers the event? If not, that is enough to say the code won't be the same.  You'll be looking at something else to control the logic within your event.  This is the perfect example of a time to build two events.

 

If you have similar functionality in both events, this is when a subVI makes sense.  Write it once, drop it into both events, and you're set.  There's no need to duplicate the code.

0 Kudos
Message 6 of 6
(1,024 Views)