Page 1 of 1

Drag and Drop in CEGUI?

Posted: Thu Jun 30, 2005 09:45
by Psih
I want to make an inventory such as in Diablo,Diablo2.
But i have never seen Drag&Drop in CEGUI. Can i do this with CEGUI? and how? (I use CEGUI with OGRE 1.0.2) May be some code wich show Drag&Drop in CEGUI will help me.



PS: sory for my english :oops: . Thanks.

Re: Drag and Drop in CEGUI?

Posted: Thu Jun 30, 2005 20:48
by J_A_X
the new version now has that option, have fun.

Re: Drag and Drop in CEGUI?

Posted: Fri Jul 01, 2005 09:01
by Psih
:D Thanks!
I have download this wersion last night. Now will try howe it work.
Somebody have some code wich show how work with Drag and Drop?

Re: Drag and Drop in CEGUI?

Posted: Fri Jul 01, 2005 09:13
by CrazyEddie
As stated, Drag & Drop is in the new 0.3.0 release.

Basically, you add whatever content you need to a DragContainer, and listen for DragDrop related events on possible target windows; you then decide what to do based upon the events you get.

I have no time to produce any sample code at present, though A wiki tutorial may be on the cards in a couple of weeks ;)

CE.

Re: Drag and Drop in CEGUI?

Posted: Thu Sep 22, 2005 18:04
by Van
I have no time to produce any sample code at present, though A wiki tutorial may be on the cards in a couple of weeks ;)

CE.


*bumps CE* ;)

Would someone please give a quick overview (here or the Wiki) of what needs to be done to implement a Drag-N-Drop? There are no examples or even code snippets to review.

I see the CEGUI::DataContainer but what is the CEGUI::DragContainerFactory for?

What is the order of creation? Does everything related to a drag-drop have to be in a container? How do you define a draggable item? How do you define a receiver?

Re: Drag and Drop in CEGUI?

Posted: Fri Sep 23, 2005 21:44
by martignasse
not tested, but by reading what CE wrote

Basically, you add whatever content you need to a DragContainer, and listen for DragDrop related events on possible target windows; you then decide what to do based upon the events you get.


Maybe you can try :

1°/
you define a draggable item by making it a child of a "DragContainer".

2°/
you make the item you want to be the receiver listening to "DragDrop" events to be informed when the drag and drop action is done on him.

hope it helps

Re: Drag and Drop in CEGUI?

Posted: Sat Sep 24, 2005 09:53
by martignasse
...and another idea,

example should be found in CEGUI itself because the MultiColumnList implement it.

try to search in CEGUI source code, in the MultiColumnList implementation.

Re: Drag and Drop in CEGUI?

Posted: Sat Sep 24, 2005 15:58
by Van
martignasse wrote:
...and another idea,

example should be found in CEGUI itself because the MultiColumnList implement it.

try to search in CEGUI source code, in the MultiColumnList implementation.


I must be blind as a bat.. I searched the entire CEGUI solution and I couldn't find an example of where DragContainer is really being implemented (except in the LUA stuff and I am not to sure what's going on there). I have this MultiColumnListBox with rows. I want to be able to drag and drop the row(s) from one window to another. Do I need to create only ONE container for the drag and drop? Or, do I need to create a container for each row in each MultiColumnListbox?

This doesn't work:

Code: Select all

   char mStr[128];
   sprintf(mStr, "Inventory/DragContainer/%s", c1);

   CEGUI::DragContainer *mDC = (CEGUI::DragContainer *)mWinMgr->createWindow(
      "DragContainer", (CEGUI::utf8*)mStr);

   unsigned int mRow = mListBox->addRow();
   CEGUI::ListboxTextItem* item = new CEGUI::ListboxTextItem((CEGUI::utf8*)c1, 0);
   mListBox->setItem(item, 0, mRow);
   mDC->addChildWindow(item);


Note the line [color=0000FF]mDC->addChildWindow(item);[/color].

Re: Drag and Drop in CEGUI?

Posted: Sat Sep 24, 2005 23:48
by Van
(CEGUI Version 0.4.0) Well, after studying the code it has become painfully obvious that Drag and Drop is not supported at the ListBoxItem level(s) - yet. It is only supported at the Window widget level. I can't figure out a way to be able to drag and frop ListBoxItems. Back to the drawing board... :x

Re: Drag and Drop in CEGUI?

Posted: Sun Sep 25, 2005 09:18
by CrazyEddie
Nobody ever said that this was supported for listbox items.

It's a pretty simple customisation to add, actually ;) You could use a similar approach to Blackharaz when he added per-item tooltips to the standard Listbox.

Re: Drag and Drop in CEGUI?

Posted: Thu Dec 15, 2005 16:59
by vinnythetrue
I too, am trying to use this DragContainer, without any success so far...

Actually, I made allmost (quite buggy) what I want, but in a really dirty way.

So, what I want is simply to be able to drag the buttons from one location to another in a button grid. The buttons are active, meaning you can click them anytime. So I just wanted to add the drag stuff.
So what I did is replace each button of the grid with a DragContainer containing the button. But I rapidly realized that the dragcontainer seems only useable when the really clicked widget is disabled....

I came out with something approaching by simply recoding the mousedown/mousemove/mouseup code in the button handlers. So when MY code detects willing to drag, I just disable the button and then inject some ButtonUp and ButtonDown inputs in the system, quite ugly heh ?

So far I just can't see better way of doing what I want, so, where am I wrong ?

Re: Drag and Drop in CEGUI?

Posted: Fri Dec 16, 2005 00:53
by lindquist
there is no easy way to overcome this problem currently. thing is that you cannot stop the button from consuming the events...

I would stick to your current approach.

Re: Drag and Drop in CEGUI?

Posted: Fri Dec 16, 2005 10:38
by vinnythetrue
That's too bad :(
So I'll probably try to code something myself when I'll have time, this ugly solution isn't really satisfying, the drag doesn't work each time (mostly when the mouse movement is really fast).

The point is that I don't really understand why the drag comportment is not part of the window object (with some flag to activate/desactivate it), it doesn't seem very natural to only drag disabled widgets...

Posted: Fri Aug 04, 2006 12:52
by bitten
Where I can find some example of drag/drop with CEGUI?

Posted: Fri Aug 04, 2006 13:34
by Rackle
My approach to Cegui so far has been that when I needed something I looked for a way (sample, tutorial) to do it, didn't find it, spent hours and hours figuring it out, debugging it, and finally writing up a Wiki for what I had discovered so that others would (hopefully) have an easier time.

I will need drag and drop eventually. But maybe your need is greater, more immediate than mine and you'll beat me to that Wiki write up :wink: