Picking IHM

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

xabila
Quite a regular
Quite a regular
Posts: 55
Joined: Tue Mar 10, 2009 09:39
Location: Bruxelles

Picking IHM

Postby xabila » Mon Jun 22, 2009 12:17

Is there a way to know if one of my layout have been picked , or clicked, in order to avoid my 3D picking.
Thanks

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: Picking IHM

Postby Jamarr » Mon Jun 22, 2009 14:57

The obvious thing to do would be to check the return value for CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton). If it returns true then you know that the mouse clicked on a CEGUI window.

That being said, there is an issue with CEGUI when clicking on a window that is already the active window; see this thread. What you could do is iterate through all of your top-level windows and call CEGUI::Window::isHit on each one, passing in the mouse-coordinates, to determine if the mouse was clicked over a CEGUI window or not...
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

xabila
Quite a regular
Quite a regular
Posts: 55
Joined: Tue Mar 10, 2009 09:39
Location: Bruxelles

Re: Picking IHM

Postby xabila » Mon Jun 22, 2009 17:44

Thanks a lot, i'm gonna check both ideas

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

Re: Picking IHM

Postby CrazyEddie » Mon Jun 22, 2009 17:59

Hi,

This topic also discusses this a bit: viewtopic.php?p=6989#p6989.

CE.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: Picking IHM

Postby Jamarr » Mon Jun 22, 2009 18:48

nice. I never even noticed that method. I have some code I can clean up with that heh...
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

xabila
Quite a regular
Quite a regular
Posts: 55
Joined: Tue Mar 10, 2009 09:39
Location: Bruxelles

Re: Picking IHM

Postby xabila » Mon Jul 13, 2009 07:02

Jamarr wrote:The obvious thing to do would be to check the return value for CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton). If it returns true then you know that the mouse clicked on a CEGUI window.

That being said, there is an issue with CEGUI when clicking on a window that is already the active window; see this thread. What you could do is iterate through all of your top-level windows and call CEGUI::Window::isHit on each one, passing in the mouse-coordinates, to determine if the mouse was clicked over a CEGUI window or not...

So First the CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton) is not working fine.
I 'm working with lots of transparent layouts and it seems that the injectMouse is catching a transparent window, i guess in order to activate it.

So i was wondering if the isHit method or getWindowContainingMouse are handled transparent layout ?
Thanks

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

Re: Picking IHM

Postby CrazyEddie » Mon Jul 13, 2009 08:41

xabila wrote:So First the CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton) is not working fine.

Yeah, the return values are totally broken at the moment - my fault, I'm going to be coming up with something of a fix in the 0.7.0 code.

xabila wrote:I 'm working with lots of transparent layouts and it seems that the injectMouse is catching a transparent window, i guess in order to activate it.

So i was wondering if the isHit method or getWindowContainingMouse are handled transparent layout ?

Those functions operate the same whether a window is transparent or not. What you need to do, as alluded to in the other thread, is use those functions to get the window that contains the mouse - you then just check whether that is one of your transparent windows - if it is, do not inject the event into CEGUI and instead do the object pick, if it's not one of the transparent windows then you do inject the event into CEGUI.

Things to consider / look out for are that getWindowContainingMouse is kind of 'free' in that it's state is maintained by CEGUI in response to mouse movement and window events, whereas isHit goes off and tests whether the mouse is in the window (so may be slightly more expensive). Something else to have to be aware of is that if you have many overlapping transparent windows, these tests may or may not work how you want - in those cases you might have to either rearrange the way the layouts are composed (so that there's only really one 'root'), or perform additional tests.

CE.

xabila
Quite a regular
Quite a regular
Posts: 55
Joined: Tue Mar 10, 2009 09:39
Location: Bruxelles

Re: Picking IHM

Postby xabila » Mon Jul 13, 2009 13:16

Ok so i should check if there is a Containing Window visible, Thanks !

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: Picking IHM

Postby Jamarr » Mon Jul 13, 2009 18:49

Would it be beneficial / simpler to setMousePassThroughEnabled(true) on all transparent windows?
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

xabila
Quite a regular
Quite a regular
Posts: 55
Joined: Tue Mar 10, 2009 09:39
Location: Bruxelles

Re: Picking IHM

Postby xabila » Tue Jul 14, 2009 06:23

I allready got the setMousePassTh... at true

So to clarify my architecture.
I have a GUIManager wich handle GUIExtension. And all the GUIExtension have there own layout...
All have a setMousePassThroughEnabled (true)
As you can see here (with 5 extensions...)
Image

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

Re: Picking IHM

Postby CrazyEddie » Tue Jul 14, 2009 09:10

Ok. I've checked some things in the code (yes, this time I actually know what I'm talking about!), and have a workable solution...

Prior to injecting your mouse button down events, you should call Window::getTargetChildAtPosition on the gui sheet / root window with the position of the mouse, if this returns 0 then the mouse is not over a Window that can be interacted with, so you should proceed to scene hit testing, if the return is other than 0, then the mouse is over an interactive UI element, so you should inject the button press.

I'd probably only recommend this approach for infrequent / low-volume inputs like button presses, if you did it for mouse movement also, you might end up paying a performance penalty (depending upon various things, of course).

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 10 guests