CGUIEnvironment Focus Behaviour

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Der Walden
Posts: 7
Joined: Fri Jul 20, 2012 2:12 pm

CGUIEnvironment Focus Behaviour

Post by Der Walden »

Hello Guys,

I have discovered that Irrlicht only allows to changes the focus of the active Gui-Elemet by left-clicking or pressing tab. This is wrong in my Opinion. Because if you do a right-click or a middle-click the Focus is not changing and the mouse-events are passed to the wrong gui-element... I have changed the following line of code in the CGUIEnvironment.cpp to fix this:

CGUIEnvironment.cpp Line 563 -> CGUIEnvironment::postEventFromUser(const SEvent& event)

        if ((event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)||(event.MouseInput.Event == EMIE_MMOUSE_PRESSED_DOWN)||(event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN))
            if ( (Hovered && Hovered != Focus) || !Focus )
        {
            setFocus(Hovered);
        }

Not a big Thing, but maybe interesting for future releases...
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: CGUIEnvironment Focus Behaviour

Post by CuteAlien »

I fear that's a too big change to make without making it controllable by the user. Focus code in games can get rather complicated (as right-click can be used for a lot more) and so just changing it might mess up existing applications (for example right-click is often used for the camera in games). But I do agree that changing focus with other mouse buttons (middle mouse as well) usually makes sense, so having an option to enable that (and maybe even enable it by default) would indeed be good.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Der Walden
Posts: 7
Joined: Fri Jul 20, 2012 2:12 pm

Re: CGUIEnvironment Focus Behaviour

Post by Der Walden »

Ok, i have tested this as well and i see no bad effect... I´m allso using mouse keys for camera and an invisible "workspace IGUIWindow" to seperate events by asking for currently hovered guielement. But i agree with you that it is possible that some apps are messed-up by such a big change in the engine... I personally have found this "bug" only because i want to display gueelement-specific contextmenues which shuld open up by right-clicking an elemet... and this is only possible when focus is changing properly :wink:.
Post Reply