Author Topic: Drag and Drop  (Read 5554 times)

UncleSi

  • Guest
Drag and Drop
« on: October 17, 2012, 05:38:11 PM »
Looking at the Drag and Drop example, I need more info. Is there a drag drop article anywhere?
I want to be able to drag items from one box to another. Each item always docks into a slot.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag and Drop
« Reply #1 on: October 18, 2012, 03:17:29 PM »
I don't believe there is a writeup for the drag & drop example. That particular example was just created to show how it can be done.

You might want to look at the inventory example instead if you want to drag things from one box to another.

UncleSi

  • Guest
Re: Drag and Drop
« Reply #2 on: October 18, 2012, 04:20:16 PM »
Yes I looked at that example, but what's the correct approach to using it in my project? I don't know where the example ends or begins...I can't tell what's meant to be reused or rewritten.

I don't understand why there's no template in the Create Widget for this? I want to drag drop sprites that can be docked in an area like the example, what the correct methodology?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag and Drop
« Reply #3 on: October 18, 2012, 09:02:19 PM »
Because all drag & drop logic is highly custom. Usually the "to" and "from" is tightly controlled by an inventory system of some kind. The UI is only used for visualizing the data. The inventory example has an example of how it can be done, but that's all it is -- an example. You will want to write your own inventory system. I certainly did for Windward.

UncleSi

  • Guest
Re: Drag and Drop
« Reply #4 on: October 19, 2012, 03:11:41 AM »
That's a great shame indeed. Every UI (winforms, swing, etc) that I know of drag and drop is not tightly bound to anything at all. Drag and drop should work the same way as a button click or any other GUI paradigm.

I follow the example down the rabbit hole and get to InvEquipment and I'm like "what the....!!!!". Why have you chosen to do it this way?

 :-\

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag and Drop
« Reply #5 on: October 19, 2012, 10:34:34 AM »
Precisely why I said: drag & drop logic is highly custom.

NGUI offers you a framework for it: you can start dragging when you get OnPress(true). You should then disable the collider of the object you're dragging. When you drop the object on something, you will get OnDrop() on that object, which lets you handle what it is you dropped on it.

What it is you're dragging, whether you can drag it, whether you can drop it in the specified slot, etc -- all of this is custom to your application.

UncleSi

  • Guest
Re: Drag and Drop
« Reply #6 on: October 20, 2012, 09:59:24 AM »
N-credibly difficult and obtuse GUI.

Dragging an draggable component from a docking container to another docking container shouldn't be so complex. Every single thing I do in this has some little niggle or quirk.