@fjason2713 wrote:
The syntax for adding listener to an ofxButton is generally as follows:
myButton.addListener( this , &ofApp::myButtonListener);
and then define myButtonListener() somewhere else in the file:
void ofApp::myButtonListener(){ ... }
This got me wondering if there is a way to utilise lambda expressions for the Listener method. This would be very useful especially when the listener method doesn’t do a lot.
I tried to write something like:myButton.addListener( this , [this] (){ *...handle the event...* });
but it fails to compile, where ofAddListener() complains: No matching function for call to ‘ofAddListener’. Is there a way to do this?
Posts: 2
Participants: 2