Page 1 of 1

[Solved] Mapping of Events -> EventArgs

Posted: Fri Dec 18, 2009 18:10
by Gokkan
Is there a document somewhere that specifies what the mapping of Events to EventArgs is?

For example, CEGUI::Window has a number of events such as: EventMouseButtonDown, EventMouseClick, EventMouseMove, etc. When I subscribe to these events, I give it a handler such as:

Code: Select all

bool foo(const CEGUI::EventArgs& args);


When I write foo, how do I know what to cast args as?

My question came about when I was trying to use MouseEventArgs for EventMouseClick but it was throwing exceptions. I looked at the demos and switched to EventMouseButtonDown instead, but I'm still curious what EventMouseClick should be using. Of course, I'm open to the possibility that I was simply doing something wrong with EventMouseClick, but I was curious how developers determine which EventArgs to use for which Events?

Thanks in advance for your time and help! :D

Re: Mapping of Events -> EventArgs

Posted: Fri Dec 18, 2009 18:36
by CrazyEddie
Hi,

First I agree that this information is not readily available / accessible. Really we should add to the docs for all the Event* descriptions that specifies the type of args you'll be passed. I'll add a mantis ticket so we hopefully will get that done in the future.

So, how can to tell the args? You still ask! Probably the best way is to look at the class member function that corresponds to the event (most events and classes have them, but not all - which is why the docs update will be important). So for example, the case you mention for Window::EventMouseClick, there is a protected member function Window::onMouseClick, by looking at the function signature we can see that the function takes a MouseEventArgs object (so you must have had a bug / issue of some kind!).

HTH

CE.

Re: Mapping of Events -> EventArgs

Posted: Fri Dec 18, 2009 18:47
by Gokkan
Cool! Thanks for the help!

Re: [Solved] Mapping of Events -> EventArgs

Posted: Fri Dec 18, 2009 19:32
by Jamarr
I'm surprised this hasn't come up before. I have also had to deal with this annoyance on more than one occasion :)

Re: [Solved] Mapping of Events -> EventArgs

Posted: Fri Feb 05, 2010 22:42
by Jamarr
For anyone looking for the mantis ticket, you can find it here: http://www.cegui.org.uk/mantis/view.php?id=321
/sneakybump

Re: [Solved] Mapping of Events -> EventArgs

Posted: Sat Feb 06, 2010 09:42
by CrazyEddie
Yeah, yeah... Some tickets take years to get done :lol:

This should not be one of those due to it being just a text fix, so... soon :)

CE.