Mouse event handling

I have a class inside my ofApp which is registering to use mouse events. i.e:

class ofApp : public ofBaseApp {
    void mousePressed(int x, int y, int button);

    menu myMenu;
}

class menu {
  void mousePressed(ofMouseEventArgs & args);
}

I want to be able to stop the mouse events being sent to the menu class at certain times. For example:

void ofApp::mousePressed(int x, int y, int button){
    if(someBool){
        //stop mouse events here so they are not sent to menu
    }
}

I’ve tried using:

bool mousePressed(ofMouseEventArgs &args);

in ofApp (I believe I can simply return true to stop the events) - but it seems I need a void return type. Is there another solution?

How about:

ofAddListener(ofEvents.mousePressed, menuInstance, &menu::mousePressed); 

void ofApp::mousePressed(int x, int y, int button){
    if(someBool){
        //stop mouse events here so they are not sent to menu
        ofRemoveListener(ofEvents.mousePressed, menuInstance, &menu::mousePressed); 
    }
}

but what might be better is wherever you set someBool you add/remove the listeners

void setSomeBool( bool inSomeBool ){
    someBool = inSomeBool;
    if( someBool ){
        ofRemoveListener(ofEvents.mousePressed, menuInstance, &menu::mousePressed); 
    }
    else{
       ofAddListener(ofEvents.mousePressed, menuInstance, &menu::mousePressed); 
    }
}

mousePressed has to be a void, but if you for some reason want to call a function that is not a void, just wrap it in mousePressed and throw away the return value in it

That helps, thanks. I didn’t think of adding/removing the listener when needed.