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).
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?
Thanks a lot.
what about creating two event cases instead of merging both events into one case?
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.
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?
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":
If you're really needing "Mouse Down" and "Value Changed" to call same code, you can do the following:
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:
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.