0
0

Couple of questions on this…

  1. It seems that although this method is called on an event instance, it sets the callback for all instances of that event? I’m only ever getting the userdata that I passed into the most recent call to setCallback, regardless of which Event* the callback is firing on.

  2. The docs suggest that "To avoid needing to process all messages simply switch on the messages you are interested in". How do I do this?

Thanks!
Nick.

  • You must to post comments
0
0

Bumping this – can anyone confirm that 1. is indeed the way that event callbacks work?

That is, that an event callback (and its userdata parameter) is set for the entire event, not for individual event instances (even though the method is called on an instance).

That would mean that if I call setCallBack on each event instance that I get, I’m actually overwriting each previous call to setCallBack for other instances of that event – and worse, if I set the callback to null for any event instance, I’m actually turning the callback off for all instances of that event.

Which is ok, because I can have per-instance callback behaviour by storing stuff in the instance’s userdata (that’s what I do now, and it works)… but the docs are not clear on this and the fact that you call the method on an event instance is confusing.

Thanks,
Nick.

  • You must to post comments
0
0

No, callback/userdata is definitely per event instance.

[quote:3j04b3zr]
2. The docs suggest that "To avoid needing to process all messages simply switch on the messages you are interested in". How do I do this?
[/quote:3j04b3zr]

Use a switch statement.

  • You must to post comments
0
0

Ok, thanks for the clarification. I’ll have another look at why it didn’t seem to work before…

[quote:1fjxe28x]Use a switch statement.[/quote:1fjxe28x]
Doh! I read it as "switch on", ie "turn on". :)

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.