LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

drawing selection rectangle into picture control

Solved!
Go to solution

I would like to program a vi that draws a selection rectangle with the mouse into a picture control.

This works so far if the user starts dragging inside the picture control. The code is actually robust against

leaving the picture and entering it again. Unfortunately this is not the case if someone starts dragging outside

the pic control. then succeeding drags are stopped after the mouse moves some pixels (about 1-10) and the

selection rect gets fixed.

Any idea, what could be wrong with the vi? Thank you!

 

 

0 Kudos
Message 1 of 2
(4,066 Views)
Solution
Accepted by topic author Labuser16383

Your problem is with the fact that you have one event structure inside another. This is generally a no-no, and should be mentioned in the help (there's a caveats section).

 

Specifically, the structure registers to start getting events when the VI enters run mode. That means that from that moment on, the inner structure will start enqueueing all mouse up events on the image, so that when you start outside and release inside, the structure remembers that event, but won't get to handle it until it actually executes. When it does execute (because there was a mouse down event in the outer one), it will handle the previous mouse up event immediately.

 

The basic solution is to only use a single event structure. You can use a cluster and a shift register to maintain state data and remember what state you're currently in, whether you need a timeout, etc., so that you know how to respond to each event.


___________________
Try to take over the world!
0 Kudos
Message 2 of 2
(4,046 Views)