Differentiating mouse events between CEGUI and Ogre

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
Obliviere
Just popping in
Just popping in
Posts: 5
Joined: Tue Sep 27, 2005 16:29

Differentiating mouse events between CEGUI and Ogre

Postby Obliviere » Thu Sep 29, 2005 17:29

Hi there, I was having some troubles with mouse events in a 3D environment rendered by Ogre, while having a CEGUI interface. It seems that when I'd click on a GUI element, the click would both interact with the GUI and with the world behind it. Despite lots of searching and experimentation, I haven't found a good way of countering this behaviour.

As an example, I stumbled on a GLSL demo posted in the Ogre forums (by nfz, I believe) that featured something very similar to my scene: a 3D environment that reacted to mouse input, but only had the GUI react when those elements were clicked by mouse. I've been trying to emulate that with little success. Any advice anyone is able to offer on the issue, or perhaps thoughts on what code I might post to clarify the issue? Thanks!

User avatar
Rellik
Just popping in
Just popping in
Posts: 5
Joined: Thu Sep 22, 2005 04:55

Re: Differentiating mouse events between CEGUI and Ogre

Postby Rellik » Fri Sep 30, 2005 01:24

Hi yeah i've seen someone else fix a similar problem by doing a test on the mouse position in relation to the interface's area. If the mouse is over the interface they then only allowed interactions with the interface if it wasn't it affected the world.
All you need is a boolean to switch on and off and do ur world interactions based on the state of the boolean. :D

User avatar
Exsortis
CEGUI Team (Retired)
Posts: 42
Joined: Mon Feb 07, 2005 17:13
Location: Palmdale, CA
Contact:

Re: Differentiating mouse events between CEGUI and Ogre

Postby Exsortis » Fri Sep 30, 2005 01:59

You want to consume the event if CEGUI uses it:

Code: Select all

if(CEGUI::System::getSingleton().injectMouseButtonDown(_mapMouseButton(e->getButtonID())))
{
     e->consume();
}


-E

User avatar
Obliviere
Just popping in
Just popping in
Posts: 5
Joined: Tue Sep 27, 2005 16:29

Re: Differentiating mouse events between CEGUI and Ogre

Postby Obliviere » Sun Oct 02, 2005 16:44

Sorry, should have clarified a couple extra things that I did.

Exsortis: I was basing my work from the GUI demo in Ogre; that is, all of the mouse events have already been programmed to consume input. My function is basically the same as yours, except that it steps through a local function to convert the input to Ogre instead of your _mapMouseButton method (could you clarify where you got this, btw? I can't seem to find it in the API). Evidently I'm not doing something though, as the consumes aren't processing for some reason.

Rellik: Someone already suggested something like this on the Ogre forums; I've just been having problems implementing it. Since my GUI isn't static (it changes shapes and such based on the state), I needed a dynamic way of doing this. To this point, I was attempting to use the CEGUI::Window::getChildAtPosition function, but this was always returning true to me, no matter what. This might have something to do with how I setup my layout though; each of the states is its own "window", so maybe that's why it's catching the input....

Anyhow, thanks for the reply, both.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 10 guests