LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to record mouse coordinate into array?

Solved!
Go to solution

Is it possible to record mouse coordinate into array? 

What I want to do :

- when I left click and hold the mouse, it start recording the mouse coordinate into an array (I'm thinking of using event structure to obtain mouse coordinate).

- when I release, it stops recording, and the next time mouse down event occurred, it will start putting mouse coordinate into the existing array.

 

Thanks in advance

0 Kudos
Message 1 of 16
(1,287 Views)

Yes, that's easily possible. Is the mouse over any specific item (e.g. 2D image, graph, etc.) or the entire panel.

 

0 Kudos
Message 2 of 16
(1,282 Views)

See if this can give you some ideas.

(You definitely need to work out more details, this is just a very rough draft)

 

altenbach_0-1650909270187.png

 

 

 

Message 3 of 16
(1,265 Views)

You can of course also simply record an array of points. It really depends what you need to do with it later.

(rest of the code stays basically the same)

 

altenbach_0-1650910219495.png

 

0 Kudos
Message 4 of 16
(1,254 Views)

This is what I tried before, there's 2 problems :

1. the dot only appears on the first click , but when I hold and drag to draw, it doesn't appear

2. the 1d elements into build array isn't accumulating, so it's only a 2x2 array forever , what I want is it keeps putting the coordinate inside the array

PULSEWannabe_0-1650951911395.png

 

0 Kudos
Message 5 of 16
(1,210 Views)

@PULSE.Wannabe wrote:

This is what I tried before, there's 2 problems :

1. the dot only appears on the first click , but when I hold and drag to draw, it doesn't appear

2. the 1d elements into build array isn't accumulating, so it's only a 2x2 array forever , what I want is it keeps putting the coordinate inside the array


1. Yes, Mouse down only activates once. Look at Altenbachs example, you need to use Mouse Move to collect more points.

2. Yes, look at what you're sending to the shift register, it's only the latest coords, not the resulting array.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 16
(1,205 Views)

ah yes I solved the 2nd problem, but for the 1st one, I want to click and hold and draw (recording coordinate from the moment I start to click and hold), then when I release, it stop recording, is it possible?

 

0 Kudos
Message 7 of 16
(1,196 Views)

That's exactly what my code does. Mouse up/down events toggle the boolean so the state is available to all other event cases.

Message 8 of 16
(1,169 Views)

@PULSE.Wannabe wrote:

This is what I tried before, there's 2 problems :

1. the dot only appears on the first click , but when I hold and drag to draw, it doesn't appear

2. the 1d elements into build array isn't accumulating, so it's only a 2x2 array forever , what I want is it keeps putting the coordinate inside the array

PULSEWannabe_0-1650951911395.png

 


Unfortunately, we cannot debug images, but there are serious flaws here. For example You read the mouse position way before the event even fires. You also have a glaring race condition dues to blatant overuse of local variables. None are needed. Your local gets read way before it gets written, so the display lags behind.

 

Thanks for pointing out that you are looking for mouse down event on a picture (not on the panel!). That makes things even easier.

0 Kudos
Message 9 of 16
(1,162 Views)

See if this can give you some ideas....

 

(see attached VI for details. LabVIEW 2015)

 

altenbach_0-1650989457802.png

 

Message 10 of 16
(1,150 Views)