LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Slider Bar Events - Best Practice?

Hello everyone.  Per customer request, I am implementing a slider bar that changes the attenuation at will.  However... this has proven slightly trickier than I thought it would.

Ideally, changing the value of the slider would trigger an event that queues the device to change the attenuation to the slider's current value.  However, sliding the bar causes a ton of events and sending this many messages to the device seems to cause it to hang up.  So I thought I'd implement a "Mouse Up" event.  Seems to be a solid solution except that with the slider, you'll never get the value exactly what you want.  So then you could change the value of the slider manually by typing it in, but then this does not trigger an event.  I thought about maybe introducing a "timer" into the event so that a message can't be queued every 50ms or so.  But I typically hate "band-aids" like that and it leaves you in a situation where you could actually not get the value you settle on.  So I was curious if anyone else out there had a solution for this type of thing.  Any thoughts or suggestions?

0 Kudos
Message 1 of 20
(2,713 Views)

I like to handle the sliders by setting a flag (Boolean) in the Value Change event and then "servicing" that changed value in the Timeout case. If the flag is set (True) whenever the Timeout executes, send the message containing the latest slider value and reset the flag (to False). You can control how often the updated value gets transmitted by the Timeout setting on the event structure.

 

 

 

 

Message 2 of 20
(2,702 Views)

To generate less events, you can set the increment property.  Your slider should "snap to" the nearest incremented number, allowing you to more easily control the value.

billko_0-1654022025901.png

edit:

billko_0-1654022137624.png

 

 

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 3 of 20
(2,697 Views)

Simply change the event to not lock the panel and have an event queue size of 1.

 

(And thank me for this idea!) 😄 (other workarounds are in the idea discussion and here for what we did before)

 

altenbach_0-1654022554682.png

 

 

Message 4 of 20
(2,686 Views)

@Photon_Dan wrote:

I like to handle the sliders by setting a flag (Boolean) in the Value Change event and then "servicing" that changed value in the Timeout case. If the flag is set (True) whenever the Timeout executes, send the message containing the latest slider value and reset the flag (to False). You can control how often the updated value gets transmitted by the Timeout setting on the event structure.

 

 

 

 


So this was something I had considered doing (or similar to) where you are essentially limiting the number of events using time.  But what I find is that you can miss the actual final value because of this.

0 Kudos
Message 5 of 20
(2,684 Views)

@billko wrote:

To generate less events, you can set the increment property.  Your slider should "snap to" the nearest incremented number, allowing you to more easily control the value.

billko_0-1654022025901.png

edit:

billko_0-1654022137624.png

 

 


Increment value set to .01 - still triggers quite a few events.

0 Kudos
Message 6 of 20
(2,682 Views)

Edit:

As usual, Altenbach comes up with the easy solution.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 7 of 20
(2,674 Views)

If you set it up as I described, the Value Change event is just setting the flag, the Timeout case is where the control terminal can be read so it will have the latest (final) value. It executes only if there are no events firing for the <Timeout> amount of time. I use something like 25 or 50 msec.

 

Message 8 of 20
(2,670 Views)

@altenbach wrote:

Simply change the event to not lock the panel and have an event queue size of 1.

 

altenbach_0-1654022554682.png

 

 


I was able to scroll from 0 to 70 in 2 seconds and triggered 150 events.  Includes time it took me to mouse from play and to click stop.

0 Kudos
Message 9 of 20
(2,660 Views)

@DailyDose wrote:
I was able to scroll from 0 to 70 in 2 seconds and triggered 150 events.  Includes time it took me to mouse from play and to click stop.

Yes, if the event case is basically empty and can be repeated in nanoseconds. As soon as the event does some actual work, many intermediary changes will be discarded and only the last one kept.

 

 

Message 10 of 20
(2,647 Views)