Setting values of ofxGui elements with code

I’m trying to change the values of other toggles in a set to mimic radio buttons (only one selected).
I can’t seem to find any public methods for setting control values programmatically.

something like

I get an error that setValue is protected. What’s the proper method? I can’t find anything suitable in the documentation.

you should be able to use


ok I tried that and I get an error “No member named set in ofxToggle”
I alos can’t find the set method in the ofxGui documentation

My code:


ofxToggle playSnd;
ofxToggle playFennesz;


 if (toggle == &playSnd) {
 } else {

Well, i don’t use ofxToggle. Did you simply try :

playSnd = true;

With ofxGui i usually go for ofParameter instead.

for a toggle

ofParameter<bool> playSnd;

for sliders

ofParameter<float> floatSlider;
ofParameter<int> intSlider;

then you can set values with


Ok I’m still working through this. Have a couple questions about pointers to ofParameter.
void ofApp::sndTogglePressed(const void* sender, bool &value) {

ofParameter* x = (ofParameter*) sender;
ofParameter val = sender;

cout << "\n toggle " << val.getName();
cout << "\n toggle : " << x->getName();

Why doesnt val.getName() work? I’m trying to get the dot notation to work just for curiosity sake. But the only way a name prints is to just cast the pointer and use arrow notation.

ok nevermind - I had to dereference it again

ofParameter<bool> val = *((ofParameter<bool>*) sender);

then val.getName() works