Change value of ofToggle

Hello,

So there is my question: I want to put all ofxToggle at false except the one with the name I send.
The toggles are stored in a group and I keep all the name of the toggle in a vector to iterate on them after:

ofxPanel *gui;
ofParameterGroup toggles;
std::string groupName;
std::vector<std::string> names;

void toggle(std::string name)
        {
            for (std::string _name : names)
            {

                std::cout << _name << " " << name << std::endl;
                if (_name != name)
                {
                    gui->getGroup(groupName).getToggle(name) = false;
                }
            }
        }

And I call this from an Event function that is trigerred when a value from the group changed:

void changeState(ofAbstractParameter &e)
{
    ofParameter<bool> toggle = e.cast<bool>();

    if (toggle == true)
    {
        toggle(toggle.getName());
    }
    else
    {
        toggle = true;
    }
}

But the problem is that no changes are done…

If you could please help me understand what I’m doing wrong here…

i’m surprised you don’t get a compiler warning but you are using the same toggle name for your function and for your temporary reference within changeState. (that being said, maybe it’s not the real problem).

(also, in general: if you post complete, compilable code it’s easier to test it out, and it ensures the problem is not elsewhere) [edit: also mention your platorm/IDE/OS version, as well as OF version]

I don’t get any error maybe because Im using xcode to launch it I don’t know :joy:
Im on a m1 pro with latest macos version, so I dont know how can I provide the compiled version…

you don’t need to provide compiled, but compilable! (whole .h and .cpp) or a zip of the src/ folder!

otherwise trying to debug your problem means having to figure out and re-make lots of details, and events are tricky to set up and use.