working with events

hello list,

I posted this on beginners but don’t seem to get an answer… so sorry for re-posting it here!

I’m trying to figure out how events work, but cannot find any reference to it…

I created a Circle Class that I instatiated in testApp, but now I want to use mouse events in them.
I tried addListener but didn’t manage to figure out how it works…

In testApp methods (draw…update…mousePressed…etc) I added circ[i]->draw() … etc. to make it work

How can I make my Circle class listen to events?

thnks,
miguel

src.zip

you need to call the mousePressed function in your circle class from testApp the same as you are calling update and draw:

  
void testApp::mousePressed(int x, int y, int button){  
    for(int i=0; i<circ.size(); i++){  
        circ[i].mousePressed(x,y,button);  
    }  
}  

do the same for mouseMoved, mouseDragged… in case you want to get that too.

hello Arturo, thanks for the reply,

Jung also suggested the same…

sorry for cross-posting… I have the same issue in the beginners forum:
http://forum.openframeworks.cc/t/working-with-events/3971/0

But isn’t there anyway to listen to those events without calling the methods from testApp?

something that from the constructor of Circle class I could call:
addEventListener(ofEvents.draw, funcToCall) ?

:slight_smile: