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??
drag'n'drop gui element?
-
randomMesh
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Re: drag'n'drop gui element?
The IGUIWindow already is drag n drop.klaudia wrote:actually (1.6) is there any way to make gui element (buttons etc) as drag'n'drop?
Yes, other elements don't support this out of the box.klaudia wrote:or i must create my own mechanism
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.klaudia wrote:and modify irrlicht??
Last edited by randomMesh on Sun Dec 06, 2009 5:38 pm, edited 1 time in total.
"Whoops..."
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.
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: drag'n'drop gui element?
Yeah right, we have it in one place :-)randomMesh wrote:The IGUIWindow already is drag n drop.klaudia wrote:actually (1.6) is there any way to make gui element (buttons etc) as drag'n'drop?
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
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
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