Make a GUI element not drag a window its in

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Reiko
Posts: 105
Joined: Sun Aug 16, 2009 7:06 am
Location: Australia

Make a GUI element not drag a window its in

Post by Reiko »

Just like when you click and drag on a button or scroll bar in a draggable window, the window that it is in won't be dragged. But if you click on an empty part of the window or on a statictext, the window will be dragged.

I have some elements (Specifically, IGUIImages) that I don't want to drag the window when the user clicks+drags on them. But I still want the window to be draggable otherwise (in other words, I'd rather not make the window undraggable).

Is this possible?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Make a GUI element not drag a window its in

Post by CuteAlien »

Returning true for mouse-events in those children should work. Dragging starts on EMIE_LMOUSE_PRESSED_DOWN so catching that should do the trick.
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
Reiko
Posts: 105
Joined: Sun Aug 16, 2009 7:06 am
Location: Australia

Re: Make a GUI element not drag a window its in

Post by Reiko »

While I understand the logic behind what you are saying, I'm not really sure how to implement it. Could you give me an example?

I dont want to stop all images from dragging the window, only 2 in particular in my program.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Make a GUI element not drag a window its in

Post by CuteAlien »

Ah right, not so trivial as you can't catch EMIE_MOUSE_MOVED for specific events in your receiver. Hm... then catch it generally and do a check for guienv->getRootGUIElement()->getElementFromPoint() and check if you receive one of those elements which you want to exclude.
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
Reiko
Posts: 105
Joined: Sun Aug 16, 2009 7:06 am
Location: Australia

Re: Make a GUI element not drag a window its in

Post by Reiko »

Well I got it working.

I have a variable in my receiver which I needed for something else, called hoveredId, which just contains the id of the currently hovered element (which is set whenever the event receiver gets a EGET_ELEMENT_HOVERED event). So I just reused that, and did this:

Code: Select all

 
                if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
                {
                        if (hoveredId == id)
                                return true;
                }
 
Where id would be the id of the element to not make the window drag when dragged on.

Thanks.
Post Reply