Can't make slider snap to positions

I am trying to make a sliding off/on switch. For this, I have instantiated a slider with min and max positions of 1 and 2, respectively.

Here is the associated block:

Screen Shot 2021-06-27 at 2.32.51 PM

However, if I move the slider somewhere in the middle, it doesn't snap to the ends (1 or 2) as it seems my code should cause to happen. (The 'sendget' calls just turn my hardware on and off).

I can sort of imagine how it could get into an endless loop, if the setting of thumbPosition to 1 or 2 causes a PositionChange event; but that doesn't appear to be what is happening - as the app doesn't hang, and the slider stays near the middle where I moved it.

Use a switch component instead

image

1 Like