ok
i’ve got this working now with ofEvents
i realised what was confusing me about the example
it wasn’t really obvious to myself what eventsObject.h is
from the look of it (the name, the #ifndef OFXEVENTSADDON_H_, etc)
it seemed like it was a special file that you had to use to work with events
rather than an example of a class
so in an attempt to help others who might get lost, from my understanding:
if class A hosts class B, and you want class B to trigger functions in class A
then rather than have a function in class B which links to class A, you use a special object called an ofEvent
ofEvent can deal with different types of data, but you can only pass through one object at a time (unlike a function where you can pass many)
you define ofEvent and the argument in class B
e.g.
ofEvent<int> mousehit; // (1)
this event has to be public, because you need to reference to it from class A
then in class A you add a listener for that event
e.g.
ofAddListener(classBinstance.mousehit,this,&classAdefinition::mouseWasHitInClassB); // (2)
then
mouseWasHitInClassB must be a function in class A which takes one argument (a reference to an int)
mouseWasHitInClassB(int &argumentName) // (3)
{
....
}
the argument name isn’t important
finally,
you need to trigger the event somehow in class B
this is done with
ofNotifyEvent(mousehit,2,this); // result is evaluating mouseWasHitInClassB(2) in class A
this was probably obvious to a lot of people
but i just couldn’t see the wood from the trees
hope this helps anyone if you get stuck!
and special thanks to arturo for his help here