Prevent Slider Value Going Negative
-
My brain is on vacation.... With my weird system of Knobs controlling each other Knob2 ends up having negative values (despite the min value being set to 0). I need to stop the value at 0. Any ideas?!
If you open the snippet and yank Knob 1 from one side to the other you will see Knob 2's value printed in the console.
HiseSnippet 1031.3ocsV0raabCDlqr2jH0lfFf9.PjKUBvUP+0j.DDTUKaGnlXG0JWibn.AT6RokvbIWrjxNBsAvOJ4QHG56S68dIuAsCIWYsajprk.pNHryOeC+lgbFxAox.pRISQdkOcVBE48k9CmIzQ8hHLAp+AHuG3eLQoooXmp8mkPTJZHxyamWXT3UdWj82m998IbhHftPEBcljEPeEKloWncP2Wx37iHgzSYw47tS29ARQOIWNE3yN9MPIjfyISnmPLtUxG4cmCCYZY5PMQSUHuc2WFNaXj7Rgy+yXJ1HN0HzDMDBjS8QRdngwFsndQLd3f44sBAQYvhpvNtpvW6eLKjcs9EUiuxZ.u.Q95gWohzamBzq4+E8VAk7xQoccT5g9CCRYI5EVL74K76KfMmwDnrmmJNeQkzk76IAOD55wjyoGkBBWin5iazXOL7WsmUoBT5UZ7EjT7KExQMwOGOG3DptmLNQJ.gpOxZ8Q.hh.ZsV.sVFP60Bn8x.5rV.cL.pvDblfhGOUDnYRAVJrz0.KUxqFLGydPT4So0p7aUJaQWWQ0mYTU0Y.hk0PqEFb9MYtXM725xibp.XkqTFVMkjSqmjx.14hRAedOD80VbMKZFm6Q37QPaP0hohgf4xxSjZ5qEUs4Sk2WA+4lFOdk1xBFmltRyl1yz0ArpXZ7HZZ9powQ3LawFg6b6ZDBb0jbNJE8EL8qSnYxquSFkUTM8zYLDbUaaedPV6yPNKjlhXPPtqushhrjO+bLzsFbqBfu5u+o+ZC.2t3JW6W+yM.bmUP6eo+ADMwL9HqP.EmDZplY1C7NfdALK1MLor+AT04ZYBr2b8wOnpci0p2g7789HrbyLe7Ijsneqw2xg+Oli+G81L7sM3yR3qF2c10BeXV2MINcb7328r7X0w3ttXb+rX7JxHJ2Fh64a+tYNtfxGmqHcujEpiLqvaJgPQT1jHsQpJXUSeG7MyRCbSbfa+VYGkfa8MJWqD9xHVPDlovvj.LQgcSelOxo1d3QS03rXP3J4mEnNyCDZSRoVKkRt8paLcdg+oQ.WSx3zhz.F.JwB5DhlcA0oSUGi6iujHzXlFClUvwPLQiaTGdZvRW6AW3JCmxI5h2Bad5QlAXhTgq9LWuITL8r78FavUyMV6Uy2VJ9P+ALcPzp4XoUvQns8+CNl8fl66e33wz.8BBtq+QuYae8xMr7+rbplIlbLQmxLMZmLMdH7lt.Jr5BAkqLmdJYZ8cxMLxlJvPpHzJ7OvuLiMMxdYFaN2HJlDjJe67S8Pw6dVM.mD1WKVFd1JHiWZ7NBECuf6sAAEC0R.ass.aus.6rs.+tsE3i2VfOYaA9zaFn4A1+vTsL101fPGO3P68ZddGJHvIP6oUz+B7XSHt.
-
You can cap it using
Math.max()
Knob2.setValue(Math.max(component.get("min"), Knob4.getValue() - Knob3.getValue()));
-
@d-healey Does that stop the slider from moving?
-
@clevername27 Not in Dan's scenario because this goes in the callback for Knob1
-
@d-healey Understood - thank you. I think what I'm asking would simply be done in my own paint routine for knob. (Maybe I could stash the limits into the tooltip or something. If it was Panel, I could just use the data extension.);
-
@clevername27 Why not use LAF instead of a panel?
-
@d-healey said in Prevent Slider Value Going Negative:
You can cap it using
Math.max()
Knob2.setValue(Math.max(component.get("min"), Knob4.getValue() - Knob3.getValue()));
Ah yes, great idea! Thank you!