@robotPatrol wrote:
hi,
i am trying to add listeners to ofxToggle using ofxGui. i found this helpful initially (https://forum.openframeworks.cc/t/vector-of-ofxgui-vector-listener-callbacks/20063) but i receive "No matching member for call to 'make_function' after creating my listener method. i'd like to add the toggle number to a list when it is 1 and erase it from the list if it is 0.
.h
ofxPanel testPanel; ofxToggle testToggle[5]; vector<int> toggleList; vector<int>::iterator toggleCntr; void testPressed(ofxToggle &toggleNumber);
.cpp
void ofApp::setup(){
for(int i = 0; i < 5; i ++){ testToggle[i].addListener(this, &ofApp::testPressed); } testPanel.setup("panel"); for(int i = 0; i < 5; i ++){ testPanel.add(testToggle[i].setup("testToggle")); }
}
//--------------------------------------------------------------
void ofApp::testPressed(ofxToggle &toggleNumber){for(int i = 0; i < 5; i ++) { if(toggleNumber == 1) toggleList.push_back(toggleNumber); else if(toggleNumber == 0) { for(toggleCntr = toggleList.begin(); toggleCntr < toggleList.end(); ++ toggleCntr) { if(*toggleCntr == toggleList[i]) toggleList.erase(toggleCntr); } } }
}
//--------------------------------------------------------------
void ofApp::draw(){
testPanel.draw();
}how can i fix the call to the addlistener?
thanks in advance
01
Posts: 14
Participants: 2