How to inject only when over frame window?

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

some_name
Just popping in
Just popping in
Posts: 15
Joined: Sat Mar 10, 2007 00:12

How to inject only when over frame window?

Postby some_name » Wed Apr 18, 2007 03:52

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?

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Wed Apr 18, 2007 07:47

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! :)

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Wed Apr 18, 2007 14:45

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.

User avatar
madmark
Just popping in
Just popping in
Posts: 6
Joined: Tue Jul 26, 2005 18:47

Postby madmark » Wed Apr 18, 2007 17:02

@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)

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Thu Apr 19, 2007 06:57

I am not sure about the exact 'return behaviour' of InjectInput, but the solution with capturing events in a default window would work. Empty spaces in a dialog are still that dialog, so you would only get events in your defaultwindow when the mouse exceeds the dialogs' boundaries.

Good luck :)

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Thu Apr 19, 2007 21:43

madmark wrote:@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.

Oh, sorry, I misunderstood your problem :)

some_name
Just popping in
Just popping in
Posts: 15
Joined: Sat Mar 10, 2007 00:12

Postby some_name » Sun Apr 22, 2007 16:22

Thanks for the help. Passing it on from the DefaultWindow might work. Meanwhile, the solution I found when mucking around, was to call

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.

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

Postby lindquist » Sun Apr 22, 2007 17:35

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


Return to “Help”

Who is online

Users browsing this forum: No registered users and 18 guests