In Lewis Lepton’s “openFrameworks tutorial - 021 ofxGui and sound”
LINK:
Lewis doesn’t use ofNotifyEvent and he sends the addListener method to the object he wants to listen to.
In another example posted on these forums:
The process seems different:
#1 ofEvent timeStampEvent instance defined
ofEvent timeStampEvent;
#2 ofNotifyEvent Notifies timeStampEvent
void testApp::update(){
if( ofGetMousePressed(0) ){
string str = ofGetTimestampString();
ofNotifyEvent(timeStampEvent, str, this);
}
} //This appears to be the beginning of the chain. ofNotifyEvent notifies timeStampEvent.
#3 A Listener Listening to timeStampEvent Triggers the eventsIn method
ofAddListener(timeStampEvent, this, &testApp::eventsIn);
#4 eventsIn method called
void testApp::eventsIn(string & eventStr){
cout << “we got an event!” << endl;
cout << “timestamp is:” <<endl;
cout << eventStr << endl;
displayString = "last timestamp received: \n" + eventStr;
}
In the openFrameworks documentation addListener is NOT sent to an object. In Lewis Lepton’s tutorial addListener IS sent to the object that it is supposed to listen to. Is this the new way of doing things? Can someone please explain how all this works? It’s very confusing.