LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Press and release mouse coordinates

Solved!
Go to solution

Hello, I'm currently working on a frequency meter including simple sound recorder. I want to implement selecting a fragment of recorded waveform by dragging pressed mouse over it. I made a VI that would do it, but it requires Mouse Down and Mouse Up coordinates. So far I've only came up with double Event Structure just like in the attached screenshot (outter structure has enabled front panel) and well, it works, but when one of the conditions isn't fullfiled (i.e. mouse was pressed inside and then released outside the Waveform Graph area or opposite) the front panel will freeze, so I believe there must be some more elegant solution. Any ideas how could I make it foolproof?event.png

0 Kudos
Message 1 of 5
(3,770 Views)

Just move the mouse up event to the outside event structure and delete the inner one.  Problem solved.

aputman
Message 2 of 5
(3,761 Views)
Solution
Accepted by topic author BobTheBeaver

You don't want to put two event structures inside of each other... technically this could work if you set up the event not to lock the panel and you do some event clearing, but it's not the simplest way in the end. You'll end up with a queue of mouse up events in the inside structure so it would be a mouse up event instantly every time after you click once.

 

Create both events in the outside event structure, then use a data cluster to store the information you need from the mouse down event. Then, in the mouse up event handle the drag and drop coordinates accordingly.

You end up with something like this:

Mouse Up.png

Ignore the broken wire, that's just something in the way LabVIEW exports the snippet. The Mouse Down event just passes the coordinates to the data cluster.

 

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 3 of 5
(3,759 Views)

You may want to have some sort of state variable stored in a shift register so that when the mouse up event occurs, you can check the variable to make sure it originated in the chart.  So basically set it to true in the mouse down.  Then in mouse up, if the variable is true, set it to false and do what you want with the coordinates.  Otherwise do nothing on mouse up. 

aputman
0 Kudos
Message 4 of 5
(3,754 Views)

Thank you a lot, looks like I was trying too hard and made the simple thing look complicated.

0 Kudos
Message 5 of 5
(3,747 Views)