LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Handle mouse up on numeric slider control - even when mouse leaves control.

Solved!
Go to solution

I've got a stumper here:

 

I have a numeric slider control that I want to snap back to 0 when the user releases the mouse button when sliding the control - sort of a physical joystick response where the stick goes back to the center when released.

 

I'm able to make this partially work by handling the mouse up event and setting the control value to 0. But the mouse up event never occurs if the user drags the slider control and leaves the slider control boundaries - and releases the mouse when the pointer is off the control. In this case, the slider value is retained and the mouse up event never occurs with respect to the numeric slider.

 

Any help is appreciated.

 

Al

0 Kudos
Message 1 of 10
(5,195 Views)
Solution
Accepted by AlGoulet
Try using the Pane->Mouse Up Event instead.
Message 2 of 10
(5,187 Views)
Darin beat me.  Anyway, I'll elaborate a bit.  Add a flag in the mouse down event for the slide saying the user pressed on it.  Then in the Pane: Mouse Up event if the flag is true reset the position to zero. Reset the flag to false again.
Message Edited by elset191 on 11-25-2009 12:45 PM
--
Tim Elsey
Certified LabVIEW Architect
Message 3 of 10
(5,184 Views)

Is this a workaround to your problem?

 

 

Edit: Two beats me, but I had to wire some stuff 😉

Message Edited by Alain S on 11-25-2009 07:52 PM
Message 4 of 10
(5,180 Views)
I also made an example to make sure what I was saying was correct, though I didn't attach it.  I will now to offer another perspective.
Message Edited by elset191 on 11-25-2009 01:04 PM
--
Tim Elsey
Certified LabVIEW Architect
Message 5 of 10
(5,170 Views)

elset191 wrote:
I also made an example to make sure what I was saying was correct, though I didn't attach it.  I will now to offer another perspective.
Message Edited by elset191 on 11-25-2009 01:04 PM

Elset-

Nice except for the one issue.  You should initiallize the Flag SR True.  If the VI exits with a False flag you miss the first mouse down event


"Should be" isn't "Is" -Jay
Message 6 of 10
(5,158 Views)
I did forget to initialize the SR.  However I would be inclined to initialize it with F.  I played around and couldn't find any cases that differed no matter if it was left uninitialized, or initialized to either true or false.
--
Tim Elsey
Certified LabVIEW Architect
Message 7 of 10
(5,154 Views)

elset191 wrote:
I did forget to initialize the SR.  However I would be inclined to initialize it with F.  I played around and couldn't find any cases that differed no matter if it was left uninitialized, or initialized to either true or false.

You right- init with false.

Test case: set slider off zero before running.

     With Init F mouse ups on the FP (not on slider) cause no reset.

     With Init T mouse ups on the FP (not on slider) cause slider reset.

 

OP

What is the desired behavior?  should slider be set to zero before the loop runs?  


"Should be" isn't "Is" -Jay
Message 8 of 10
(5,151 Views)

You cats are awesome! The solutions work like a champ.

 

Thanks again for the quick responses!

 

Al

0 Kudos
Message 9 of 10
(5,135 Views)

This post helped me identify my problem, so I thought I would post my solution.

 

The above works just fine until the user drifts off of the LabVIEW pane altogether. Check out how I got around this in the Developer Zone Community.

 

 

---

Peter Flores
Applications Engineer
Message 10 of 10
(4,844 Views)