Can't Add Listener to ofxToggle


#1

I’m getting an error “Can’t Add Listener to ofxToggle” when I try and add an event listener to a toggle in setup. Works fine if the I use buttons instead of toggles. What am I missing? Thanks!

cpp File

void ofApp::setup(){
    ...
    myToggle.addListener(this, &ofApp::toggleBtnPressed);
    guiProperties.setup("Properties", "Properties", 10, 60);
    guiProperties.add(myToggle.setup("myToggle", false));
    ...
}
void ofApp::exit(){
    myToggle.removeListener(this, &ofApp::toggleBtnPressed);
}

void ofApp::toggleBtnPressed(){
    myFunc();
}



#2

Hi!
The listener for the ofxToggle should have an argument, like:

void ofApp::toggleBtnPressed(bool & value){

}

:slight_smile:


#3

Magical! Thank you so much :smiley: