Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
openFrameworks - callback parameterGroup . ofParameterGroup / Changed_params / name = e.getName()
// .h
ofParameterGroup params{"PARAMS"};
void Changed_params(ofAbstractParameter &e);
bool DISABLE_Callbacks = false;//to avoid callback crashes or to enable only after setup()
// .cpp
// setup()
//params
SHOW_gui.set("SHOW_gui", true);
params.setName("AppSettings");
params.add(SHOW_gui);
params.add(SHOW_User);
...
ofAddListener(params.parameterChangedE(), this, &ofApp::Changed_params); // setup()
ofRemoveListener(params.parameterChangedE(), this, &ofApp::Changed_params); // exit()
// callback for a parameter group
void ofApp::Changed_params(ofAbstractParameter &e)
{
if (!DISABLE_Callbacks)
{
string name = e.getName();
ofLogNotice() << "Changed parameter named: " << name << " : with value " << e;
if (name == SHOW_gui.getName())
{
if (SHOW_gui)
{}
}
else if (name == SHOW_User.getName())
{
if (SHOW_User)
{}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment