The way you are trying to do it will also work, but you need to include the slider's x position as well as the width.
the lower clamp value should just be Slider.X
the upper clamp value will be Slider.X + Slider.Width
so the full clamp expression will be:
Knob - set X to clamp(self.X, Slider.X, Slider.X + Slider.Width)
Thanks for the reply AllanR it seems like you understand what I'm trying to do which is simply trying to emulate the default C3 slider (I even use the same instance variables) but with my own sprites.
Dop's example is kind of cool with image points as the limiters and I should play more to understand how it works since it's new to me.
What happens when I use the code you shared is that it's not "sitting" on the correct position but more to the right so I can always play with the numbers manually I guess but maybe it's not very efficient, all I know it works (on the specific example):
BTW I tried slider.width /2
but because of the slider graphics it need the less 10 pixels anyway so I can add -10 at the end, but... it's the same result. that's where dop's image point is kind of nice! I just need to have a deeper look of how it works with the values.
I will have to explore Dop's example to try understand how I can CONNECT the current Value (using the actual instance variables) without the slider size and it's limits on the Dragging code.
In other words, the slider limiters should ONLY stay visual, that's probably where I should somehow also connect the STEPS variable.
After all my goal is to connect the INSTANCE variables to effects properties or other variables.
So I'll better keep the experiments using your examples, thank you for sharing and explaining! :)