How to add a listener to ofxColorSlider?


#1

I need to update a model when a colour is selected from the GUI. How can I do that with ofxColorSlider? Or is there another option?


#2

I prefer to use ofParameter instead of ofxColorSlider.

in ofApp.h

ofParameter<ofColor> color;

void updateModel(ofColor&);

ofEventListener colorListener;

ofApp.cpp

void ofApp::setup(){
//.....
gui.add(color.set("color",  ofColor(255,0,0,255),  ofColor(0,0,0,0), ofColor(255,255,255,255) ));

colorListener = color.newListener(this, &ofApp::updateModel);

//.....
}
void ofApp::updateModel(ofColor& c){
//update your model 
}


#3

Thank yoU!