How do I get the MouseEvent data?

Discussion regarding the development of CEGUI itself - as opposed to questions about CEGUI usage that should be in the help forums.

Moderators: CEGUI MVP, CEGUI Team

User avatar
Sponge
Just popping in
Just popping in
Posts: 16
Joined: Tue Nov 08, 2005 18:17
Location: Fryslan, The Netherlands
Contact:

How do I get the MouseEvent data?

Postby Sponge » Mon Nov 21, 2005 15:26

Hi :P,

I can't exactly figure out how to get the mouse event data. I'm passing data from a Lua event to the C++ function. I can get the window data, but not the mouse data.

Notw: I'm using the "Clicked" which is set by a property in the XML layout file.

LUA:

Code: Select all

 function cmdIngameBuild_click(args)
   ....
   
    guiman:BuildItemClick(args)

   ....
 end


Declaration BuildItemClick:

Code: Select all

void BuildItemClick(const CEGUI::EventArgs& args);


Casting code:

Code: Select all

   //Proper conversions:
   CEGUI::MouseEventArgs  argMouse  = static_cast<const CEGUI::MouseEventArgs&>(args);
   CEGUI::WindowEventArgs argWindow = static_cast<const CEGUI::WindowEventArgs&>(args);
   CEGUI::PushButton* btn = static_cast<CEGUI::PushButton*>(argWindow.window);


The last two ones work. The MouseEventArgs are not initialized at all and contain a lot of junk data. I've searched the entire CEGUI solution collection, but no luck in finding an example.

Any idea? :)


---

hm, I just realized that this is the incorrect forum. Hm, oh well :P :oops:

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

Re: How do I get the MouseEvent data?

Postby CrazyEddie » Mon Nov 21, 2005 18:57

The push button "Clicked" event handler is passed a WindowEventArgs& which is not a MouseEventArgs& so attempting to cast to that is an illegal cast.

You'd have to let us know exactly what you're doing so we could advise on how to get the information you're after.

User avatar
Sponge
Just popping in
Just popping in
Posts: 16
Joined: Tue Nov 08, 2005 18:17
Location: Fryslan, The Netherlands
Contact:

Re: How do I get the MouseEvent data?

Postby Sponge » Mon Nov 21, 2005 21:48

Hm. I want to which button was pressed for the "click" event, and possibly the scrollwheel as well (just a usability thing). Since this was the 'clicked' event I assume it had MouseEvent args as well. (Which looked a bit obvious to me)

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Re: How do I get the MouseEvent data?

Postby lindquist » Tue Nov 22, 2005 00:19

the "Clicked" event only occurs on the left button.
you can't really get much info other that the window clicked!

User avatar
Sponge
Just popping in
Just popping in
Posts: 16
Joined: Tue Nov 08, 2005 18:17
Location: Fryslan, The Netherlands
Contact:

Re: How do I get the MouseEvent data?

Postby Sponge » Tue Nov 22, 2005 08:59

Hm, I didn't know that. I'll check out an alternative, (probably a simple left/right click function which call the same function but with a different argument, unless I similar click event which does do both) Thanks! :)

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

Re: How do I get the MouseEvent data?

Postby CrazyEddie » Tue Nov 22, 2005 11:02

There is a "MouseClick" event, which is fired for all buttons, although this functions at a lower level that the button (so has slightly different logic), but it might be worth playing with :)

User avatar
Sponge
Just popping in
Just popping in
Posts: 16
Joined: Tue Nov 08, 2005 18:17
Location: Fryslan, The Netherlands
Contact:

Re: How do I get the MouseEvent data?

Postby Sponge » Tue Nov 22, 2005 11:31

Yeah, I'm using the MouseUp event now. Seems to work just as well as Clicked(). Right now I'm onto the placing of objects onto the terrain :).

btw, I was wondering. If I have a default window, the root element, which is (ofcourse) the full window size. If I put a scrollwheel handler on that, will it trigger as well when there is a child window under the mouse?

So:

Code: Select all

Root
|_Static image
   |
   - Button


So, if I perform a scrollwheel event above the button, will the root still get the event?

And what if the root has a MouseUp event, and a button as well. Will the event follow the hierarchy or not? If so, then I makes things quite easier to have only one MouseEvent system instead of having two (one for the interface, and one for the "in game 3D stuff". :)

Just wondering :P

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

Re: How do I get the MouseEvent data?

Postby CrazyEddie » Tue Nov 22, 2005 19:41

Most injected events that are not somehow consumed by a widget, eventually find their way back to the root window, so you should indeed be able to do what you want ;)


Return to “CEGUI Library Development Discussion”

Who is online

Users browsing this forum: No registered users and 0 guests