Hi,
First of all: please notice that ofxUI has been deprecated by the developer. And as such when starting on new projects it is advisable to take a look at the other GUI's now available, like ofxImGui or ofxDatGui.
On-topic: When adding a widget to an ofxUICanvas you can return a pointer to the widget. You can then use this pointer to change the value(s) of the widget.
For instance, with an ofxUILabel:
//add a label
ofxUILabel myLabel = (ofxUILabel *) myCanvas->addWidget(new ofxUILabel("MY_LABEL_ID", "Hello world!", OFX_UI_FONT_MEDIUM));
//and then to change the label text
myLabel->setTextString("Hello again, world!");`
or in your case:
ofxUISlider mySlider = myCanvas->addSlider("MY_SLIDER_ID", 0, 100, 50); // init slider with value of 50
mySlider->setValue(75.f); // slider now has value of 75`
Please note the (ofxUILabel *)
bit. When using addWidget
ofxUICanvas returns a pointer to the ofxUIWidget
superclass when adding widgets, and to be able to call the actual widget's functions you need to cast it to the proper subclass. This is not the case when using a subclass-specific method, like canvas->addSlider etc