being new to TouchDesigner and wanting to do seemingly basic things can get frustrating at times. Although I found this thread ( Reset Value to TUIK slider - #3 by keithlostracco ) which basically does what I would like to do I have no clue at all on how to implement that in my project as I am using slider widgets
What I would like to achieve:
Have several sliders on screen that I can drag via mouse or touch.
Have a reset button that resets all sliders to different pre-set values.
What I currently have:
A constant CHOP and an invisble slider widget which both send their values to an override CHOP which then updates the value of a visible slider widget underneath the invisible one. When updating the constant with a different value it overrides the visible slider value.
Current problem:
The constant value only overrides the slider value when it´s value is different to the current one, therefore updating the constant with the same value does not trigger the override.
Questions:
Is it possible to resend the same constant value to the override in a way that it is triggered? (I tried using delay but to no avail)
Is there a more elegant way than what I hacked together with my limited knowledge?
So it seems I have found another way by, instead of trying to get a delay running within python, using a delay CHOP to execute two DAT CHOP executes one after the other. Setting the constant to 0 first and in the next frame to the wanted value the override detects the value change and acts as expected.
Man this really looks and feels messy, but at least it works
Final Question:
Is there a more elegant way to reset a slider widget?
Is that the slider from the UI/Basic Widgets section of the Palette?
If so why not just do:
def myResetFunction(...):
my_slider.par.Value0.reset() // if you set the default value of the par
// or
my_slider.par.Value0 = my_reset_value
Then just call/trigger it with no delays, no extra sliders etc… With current panels widgets the slider view is always bound to the value.
If you want to update the view of the slider and not have it update any values anywhere, then that’s a bit trickier.
You either have to disconnect it (reference etc…) from whatever you’re setting then do the same as above (which is a pain and problematic).
Or you need to make your own slider that separates the view from the data (which seems to be what you’re doing with the hidden slider). Then you can call something like UpdateView() to set the look (position, value field) of the slider and then the slider itself can call UpdateView and another function such as SetValue (only when a user interacts with it…)
UpdateView() → sets the look - field, knob position etc…
SetValue() → sets the value of something.
SetValue() is called on something like panel.u if panel.lselect (is True) and sets the value somewhere when someone interacts with it.
UpdateView() is called on panel.u if panel.lselect and can be called by something external such as a reset or a preset object.
Then if you want to reset the slider you have a choice, reset just the view or reset the view and the thing the slider is supposed to be controlling.
Your snippet works as expected whilst a follow up interaction with the slider still works. It seems like I must have written something wrong several times while trying to do a reset via python which then lead me to develop that super clunky setup above #noob
So now everything works as expected and exactly how I initially thought it should, just a line of code to overwrite the slider value ones.