Listen to ofEvent ofxPanel::savePressedE


I’m looking for implement a event listener for the following event in order to prevent it in some case but I’m unable to make it works.

ofEvent ofxPanel::savePressedE

Can somebody explain me to implement such event handler function in .h & .cpp files ?


I’m afraid that you cannot avoid saving by listening to that function.
Anyways, let’s say you’ll implement the listener function in ofApp,
declare it in ofApp.h. like this:

ofxPanel gui;// or however you called your instance of ofxPanel

bool listenerFunction();
//  void listenerFunction(); // you could also have it returning nothing if you dont care about event propagation.

and in ofApp.cpp

void ofApp::setup(){

ofAddListener(gui.savePressedE, this, &ofApp::listenerFunction);


bool ofApp::listenerFunction(){
 //Implement this function in any way that you might need 
 //but remember to return true if you handled the event, which means that it will stop propagating 
 //or false for the opposite.

that’s all. hope it helps.