Thrown off by the bool return of ofNotifyEvent

the docs for bool ofNotifyEvent(...) says

but as far as I can breakpoint or log, it’s always false, even for internal events like draw etc.

the different callers are passing the potato along down from this origin:

which is actually returning the result of the function, and not “was the event attended”. all the listener call backs are type as void returns.

for example, the ofSimpleEventExample() uses:

changing them to bool that return true makes the ofNotifyEvent return true. so:

  1. is the doc wrong and should it say “passes the return value of the callback, which should be a bool, presumably indicating if the processing was successful, but that’s up to the callback writer”

  2. is the implementation wrong and should line 96 of ofEvent.h be simply the function(s,t) call and line 97.5 return true? (we don’t care what the listener did, only that it got the event without exception).

  3. I’m confused and there is something else going on? maybe “attended” is meant for something else. does anything internal rely on that return value and/or is there a case of a callback that does not return void?

found that the mouse button in ofxBaseGui reports bool:

other everything else seems void; for instance the ofApp mouse stuff is void:

so a 4th hypothesis:

  1. this attended variable is a special ofxGui things that evaded into the public API (the ofxGui pattern seems to mean “this callback is supported by this ofxGuiClass” – the design is that all the ofxGuiClasses have to implement all the callbacks and return false on those that don’t make sense).

you can either pass functions that either return void or bool.
When returning a bool, then if the function returns true it means that the event was attended and it no longer propagates to the remaining listeners of the event. when false it continues calling the next listeners.

ah OK the receiver can “consume” the event — that makes sense from a GUI coherence point of view (and perhaps also other structured contexts), but what is the purpose of getting that result at the “general purpose” ofNotifyEvent() level?

the docs are not as clear as what you just wrote; “attended” should perhaps be changed to “consumed”, and indicate that callbacks written like that terminate the propagation? something like:

// if true: the event propagation was interrupted by a greedy listener
// (and other listeners may have gotten the event, depending on notification order)
//
// if false: the event propagation was not interrupted by a greedy listener
// (and may or may not have been received by one or more listeners)

and somewhere document that a listener can return true to behave greedily.

so now an actual question: is there a way to know that an ofNotifyEvent(…) call was received by one or more listeners?

or should the pattern be to check if there are subscriptions through MyEvent.size()?

I have no idea but I guess it has to do with a C++ thing where you can’t have function overrides that differ on their return type. So, in this case you always return a bool.

well it depends on how you understand the events system. I think both “attended” and “consumed” are correct. Yet being clearer wont hurt.

I am not sure but I dont think so.

most probably.
But why do you need to know such?

But why do you need to know such?

I have a context where the binding of events is dynamic and some postprocessing needs to occur if the event ended up somewhere.

reading the docs made me believe “any listener attended the event” meant that, but it does not…

so I’m going to test for .size() and presume if there are listeners that they got the event.

about terminology perhaps “consumed” is not better but for sure the notion of interrupting the propagation is the concept that is transmitted in that return value. I am not sure it is logical design to have ofNotifyEvent (a user-facing function) return that value. as seen here the true result serves within notify() itself to return early: