I’m trying to add an event listener for a button and it works 90% of what I need it to do but it gets called over and over again and I cant seem to figure out why.
Try yo declare your button as follows in ofApp.h; ofParameter<void> button = {"Select file"};
then the rest is same. But do not initialize button in add method this time;
void ofApp::setup(){
button.addListener(this, &ofApp::button_pressed);
gui.setup();
gui.add(radius.setup("radius", 140, 10, 300));
gui.add(button); // No need to initialize the button object here, you did it in your header file
}
Hi, So I’ve fixed the problem, turns out I left the old code from before I added the event listener in the draw function so it was getting called from draw.