drag'n'drop gui element?

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
klaudia
Posts: 20
Joined: Thu Jun 18, 2009 2:39 pm

drag'n'drop gui element?

Post by klaudia »

actually (1.6) is there any way to make gui element (buttons etc) as drag'n'drop?
in compiled irrlicht library?
or i must create my own mechanism and modify irrlicht??
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: drag'n'drop gui element?

Post by randomMesh »

klaudia wrote:actually (1.6) is there any way to make gui element (buttons etc) as drag'n'drop?
The IGUIWindow already is drag n drop.
klaudia wrote:or i must create my own mechanism
Yes, other elements don't support this out of the box.
klaudia wrote:and modify irrlicht??
You don't need to modify Irrlicht for that. Just check if the mouse hovers an element when you receive a mouse button click event, then move that element as long the user presses the mouse button and moves the mouse.
Last edited by randomMesh on Sun Dec 06, 2009 5:38 pm, edited 1 time in total.
"Whoops..."
CuteAlien
Admin
Posts: 9926
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Sorry, no drag 'n drop for GUI elements so far. I'm also not sure if it would be that easy to implement for most gui-elements as it would conflict with normal behaviour (like a button should usually be pressed down on a click).

Maybe it would be possible to do it in some way without changing the engine. Not sure if it work, I would have to think more about that, but as a first idea - maybe it would be possible to have a dragdrop element added as child to other gui-elements which can be put above other gui-elements. It would pass most events on to it's parent (maybe buffered and delayed?). On click+mouse move it would move it's parent around.
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
CuteAlien
Admin
Posts: 9926
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: drag'n'drop gui element?

Post by CuteAlien »

randomMesh wrote:
klaudia wrote:actually (1.6) is there any way to make gui element (buttons etc) as drag'n'drop?
The IGUIWindow already is drag n drop.
Yeah right, we have it in one place :-)
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
Abraxas)
Posts: 227
Joined: Sun Oct 18, 2009 7:24 am

Post by Abraxas) »

I accomplished this using the EventReceiver and global variables MouseMoveX MouseMoveY.

Two tips. First of all, assign a UNIQUE ID to your Gui element, and have that gui element be in an array indexed to the unique ID. There is a 'element hovered' event, so check the hovered ID, store it in a global (its the easiest way IMO).

mousemove variables would be (posthisframe - poslastframe).

DONT scale. Use actual resolution. Scale afterwards if you need to save the position.

then in the same eventreceiver, in a mouse button hold event (or whatever) set the window position offset by mouse movement if ID == WINDOWID.

Take about 10 minutes to code and test :)
Post Reply