It is quite straight forwads as arturo says, just put a button in the gui and listen to it.
Yet, I have a doubt.
@arturo, is it possible to listen to the parameter event for a function with no arguments?
This would be useful when making a lot of different parameters to callback the same function without having to create several other functions, one for each ofParameter type that just call this no-argument function.
Something like going from
ofParameter<float> floatParam;
ofParameter<ofVec3f>vecParam;
...
floatParam.addListener(this, &someClass::floatListenerFunction);
vecParam.addListener(this, &someClass::ofVec3fListenerFunction);
void someFunctionWithNoArgs(){
//make something
}
void floatListenerFunction(float& f){
someFunctionWithNoArgs();
}
void ofVec3fListenerFunction(ofVec3f& v){
someFunctionWithNoArgs();
}
to this
ofParameter<float> floatParam;
ofParameter<ofVec3f>vecParam;
...
floatParam.addListener(this, &someClass::someFunctionWithNoArgs);
vecParam.addListener(this, &someClass::someFunctionWithNoArgs);
void someFunctionWithNoArgs(){
//make something
}
Does it make sense? at least for me it does.
I know that using an ofEvent lets you call back a no args function. but how should this be managed inside ofParameter, as the event uses the same type as the parameter? Just adding a void event should make the job but would it be correct?
Best!