Is there a way to know if one of my layout have been picked , or clicked, in order to avoid my 3D picking.
Thanks
Picking IHM
Moderators: CEGUI MVP, CEGUI Team
Re: Picking IHM
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...
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!
Re: Picking IHM
Thanks a lot, i'm gonna check both ideas
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Picking IHM
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Picking IHM
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!
Re: Picking IHM
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
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Picking IHM
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.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Picking IHM
Ok so i should check if there is a Containing Window visible, Thanks !
Re: Picking IHM
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!
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Picking IHM
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.
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.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Who is online
Users browsing this forum: No registered users and 2 guests