Child windows steal mousewheel from Parent [Workaround]

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

enemymouse
Just popping in
Just popping in
Posts: 5
Joined: Sun Dec 13, 2009 08:57

Child windows steal mousewheel from Parent [Workaround]

Postby enemymouse » Sun Dec 13, 2009 10:05

Hello CEGUI people, I hope this post is all in order.

Here is the issue:

ItemListbox doesn't receive scroll events if the cursor is over an ItemEntry. Same behaviour with the Thumb and inc/dec buttons of my Scrollbars.

Is there a property I can set in the .looknfeel or some System flag to allow just the scroll events to propagate up the chain? MousePassThroughEnabled isn't feasible. I tried it on the ItemEntries just to see and still, no scrolling happened when the mouse was over one of them.

Or do I just need to add this behaviour to my mouse injecting logic?

Or am I just doing it wrong, and this is supposed to work by default.

Thanks in advance.

Here's a portion of the log:

Code: Select all

13/12/2009 04:22:18 (Std)    ---- Version 0.7.1 (Build: Oct 25 2009 Debug Microsoft Windows MSVC++ 9.0 32 bit) ----
13/12/2009 04:22:18 (Std)    ---- Renderer module is: CEGUI::OgreRenderer - Official OGRE based 2nd generation renderer module. ----
13/12/2009 04:22:18 (Std)    ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
13/12/2009 04:22:18 (Std)    ---- Image Codec module is: OgreImageCodec - Integrated ImageCodec using the Ogre engine. ----
13/12/2009 04:22:18 (Std)    ---- Scripting module is: None ----
Last edited by enemymouse on Sun Dec 13, 2009 20:46, edited 1 time in total.

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

Re: Child windows steal mousewheel from Parent

Postby CrazyEddie » Sun Dec 13, 2009 10:12

Hi,

Event handling and event propagation were changed in 0.7. The issue you're seeing is apparently a side effect of this and should be considered a bug in the system. There is no really easy work around for client code that comes to mind.

CE.

enemymouse
Just popping in
Just popping in
Posts: 5
Joined: Sun Dec 13, 2009 08:57

Re: Child windows steal mousewheel from Parent

Postby enemymouse » Sun Dec 13, 2009 10:26

Understood and thank you, that was quick.

enemymouse
Just popping in
Just popping in
Posts: 5
Joined: Sun Dec 13, 2009 08:57

Re: Child windows steal mousewheel from Parent

Postby enemymouse » Sun Dec 13, 2009 20:36

Figured I'd post my preliminary workaround. Seems to do the trick.

Code: Select all

        /// In an OIS mouse movement listener
        .
        .
        .
        /// check for mouse wheel movement
        if(arg.state.Z.rel)
        {
            /// normalize
            float wheelMove = 1.0;
            if(arg.state.Z.rel < 0)
                wheelMove = -1.0;
           
            /// force wheel to the first window having property "WantsMouseWheel" == "True",
            /// starting at target, working up the chain
            CEGUI::Window* target = CEGUI::System::getSingleton().getWindowContainingMouse();
           
            if(target)
            {
                /// save the active window
                CEGUI::Window* root = CEGUI::System::getSingleton().getGUISheet();
                CEGUI::Window* prevActive = root->getActiveChild();
               
                /// the heart
                while(target)
                {
                    if( target->isPropertyPresent("WantsMouseWheel")
                        && target->getProperty("WantsMouseWheel")=="True"
                        && target->isVisible()
                        && !target->isDisabled())
                    {   
                        break;
                    }

                    target = target->getParent();                   
                }       
               
                /// trick
                if(target)
                {
                    target->activate();
                    target->captureInput();
                }

                /// inject
                CEGUI::System::getSingleton().injectMouseWheelChange(wheelMove);

                /// restore
                if(target)
                {
                    target->releaseInput();
                    if(prevActive)
                        prevActive->activate();
                }               

            }
        }


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

Re: Child windows steal mousewheel from Parent [Workaround]

Postby CrazyEddie » Mon Dec 14, 2009 19:58

Nice hack :P

This is much more substantial than what we're used to seeing, hehe.

CE.

renovatio.forever
Just popping in
Just popping in
Posts: 3
Joined: Fri Sep 24, 2010 15:45

Re: Child windows steal mousewheel from Parent [Workaround]

Postby renovatio.forever » Wed Oct 06, 2010 07:46

Hi,

It is not a new topic but i have the same problem now with my ScrollablePane as It just scrolls on scrollbars not on window itself. So i was wondering if we can do same hack by using

Code: Select all

Window::setMousePassThroughEnabled()
Window::setMouseInputPropagationEnabled(bool)


functions.?

Or there is a new approach on 0.7.2 version?

Thanks

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

Re: Child windows steal mousewheel from Parent [Workaround]

Postby CrazyEddie » Wed Oct 06, 2010 09:23

Code: Select all

Window::setMouseInputPropagationEnabled(bool)

is the function that should get this working (and was added for this purpose). You could alternatively set the associated property ("MouseInputPropagationEnabled") either in a layout or in LookNFeel (if you always want a particular widget type to propagate inputs)

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 8 guests