Mouse Event handlers?

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
NSXEagle
Just popping in
Just popping in
Posts: 14
Joined: Wed Jan 12, 2005 12:06
Location: Kokubunji-shi, Tokyo-to, Japan
Contact:

Mouse Event handlers?

Postby NSXEagle » Thu Feb 03, 2005 10:06

I have a question related to event handlers. Yesterday, I implemented a simple picking function. I subscribed a Window::EventMouseButtonUp event to the root window of my GUI. Now here is my problem: The signature of my picking handler is:

Code: Select all

bool defaultPickingHandler(EventArgs& e)

Since the function is only called when a MouseButtonUp event was fired, I tried to get a pointer or a reference to MouseEventArgs, but as the parameter is a EventArgs&, no type conversion is possible. How can I obtain the correct MouseEventArgs in my handler function?

User avatar
walaber
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Sun Jan 23, 2005 10:20
Contact:

Re: Mouse Event handlers?

Postby walaber » Fri Feb 04, 2005 09:06

you should be able to safely cast to a MouseEventArgs object.

((CEGUI::MouseEventArgs)e)->button


..etc

User avatar
NSXEagle
Just popping in
Just popping in
Posts: 14
Joined: Wed Jan 12, 2005 12:06
Location: Kokubunji-shi, Tokyo-to, Japan
Contact:

Re: Mouse Event handlers?

Postby NSXEagle » Fri Feb 04, 2005 12:57

OK, I found the solution. All I had to do was to cast the "const EventArgs&" to an "const MouseEventArgs&". I don't know how I could've done this one wrong, but I think this was one of the dumb errors that happen to everyone of us... :?

It was only a matter of the right combination of types! :D

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Mouse Event handlers?

Postby CrazyEddie » Fri Feb 04, 2005 14:39

Yeah, this is very easily done :)

One of my most common mistakes is missing the reference specifier (&), then the cast goes totally wrong due to me having a sliced copy of the args instead of the reference :oops:

All good fun though ;)

CE.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 16 guests