I'm using CEGUI with Ogre. I have a number of frame windows that are all children of a GuiSheet that is loaded as a GuiLayout. I'm using OIS (the Ogre input system) in buffered mode, and injecting the events (mousemove, mousedown, etc).
What I want to do is know whether the event actually happened over a FrameWindow or not. If the event (mouse down or mouse move) was not over a frame window, I'd like to go ahead and do things to the 3D scene in Ogre instead.
I know how to do this with modes -- press escape to get the cursor, which sends all events to CEGUI. Press escape again to deactivate the GUI, and send all the events to the scene. But that's not good enough -- I want the best of both worlds!
What's the best way to do this? Is there some return status I can get for an event injection? Or do I have to separately ask CEGUI what window the cursor would be over?
How to inject only when over frame window?
Moderators: CEGUI MVP, CEGUI Team
- scriptkid
- Home away from home
- Posts: 1178
- Joined: Wed Jan 12, 2005 12:06
- Location: The Hague, The Netherlands
- Contact:
Hi,
what should work is putting all your frames into a fullscreen helper DefaultWindow (which is invisible) and have that listen to the mouse events (too) and pass them to Ogre. So the layout becomes:
-GUISheet
--DefaultWindow (size of 1,1!)
---Frame1
---Frame2
---...
Another option is to -as you suggest- ask CEGUI which window has the mouse. This can be done by calling 'getWindowContainingMouse()' on the System object and then act accordingly. But the first option might be cleaner.
Good luck!
what should work is putting all your frames into a fullscreen helper DefaultWindow (which is invisible) and have that listen to the mouse events (too) and pass them to Ogre. So the layout becomes:
-GUISheet
--DefaultWindow (size of 1,1!)
---Frame1
---Frame2
---...
Another option is to -as you suggest- ask CEGUI which window has the mouse. This can be done by calling 'getWindowContainingMouse()' on the System object and then act accordingly. But the first option might be cleaner.
Good luck!
If you take a look at the API reference, you can read this:
Code: Select all
bool CEGUI::System::inject........
Returns:
* true if the input was processed by the gui system.
* false if the input was not processed by the gui system.
@Pompei2
That works fine for stuff the mouse does that gets acted upon, but not for stuff that no widget claims, like whitespace in a dialog box.
@scriptkid
So, to be clear on this idea (which I really like) only mouse events that get to the DefaultWindow would get passed into the 3D scene's mouse event handler. Do you think this will work for the above situation (whitespace)
That works fine for stuff the mouse does that gets acted upon, but not for stuff that no widget claims, like whitespace in a dialog box.
@scriptkid
So, to be clear on this idea (which I really like) only mouse events that get to the DefaultWindow would get passed into the 3D scene's mouse event handler. Do you think this will work for the above situation (whitespace)
Thanks for the help. Passing it on from the DefaultWindow might work. Meanwhile, the solution I found when mucking around, was to call
Then I test whether the getType() of that window is DefaultWindow, and if so, don't inject the event.
Code: Select all
CEGUI::Window *win = CEGUI::System::getSingleton().getWindowContainingMouse();
Then I test whether the getType() of that window is DefaultWindow, and if so, don't inject the event.
- lindquist
- CEGUI Team (Retired)
- Posts: 770
- Joined: Mon Jan 24, 2005 21:20
- Location: Copenhagen, Denmark
A (probably) better way to use that function would be to test if the returned Window* equals the return value of System::getGUISheet.
e.g. if the gui sheet contains the cursor, you're not inside any other windows. checking for type is prone to errors, as DefaultWindow is often used a packing container and not only as gui sheet.
also note that the getWindowContainingMouse method is updated when mouse motion is injected... so you should generally always inject. then decide whether to pass on the input to your app/game after...
HTH
e.g. if the gui sheet contains the cursor, you're not inside any other windows. checking for type is prone to errors, as DefaultWindow is often used a packing container and not only as gui sheet.
also note that the getWindowContainingMouse method is updated when mouse motion is injected... so you should generally always inject. then decide whether to pass on the input to your app/game after...
HTH
Who is online
Users browsing this forum: No registered users and 5 guests