Author Topic: OnDrop doesn't work when I drop the item on my dragged slot;  (Read 3329 times)

minileen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
OnDrop doesn't work when I drop the item on my dragged slot;
« on: January 27, 2014, 09:48:55 PM »
the problem is:

i dragged a item from one of my inventory slot, let's say slot NO.9!
and then I regreted, so I want to put it back where it was,the NO.9 slot!
but when i drag the item back to the slot NO.9, and i release the mouse button, it just dont drop! !

so i want to fix this, i have customized the UIItemslot to my design : i can only chang the inventory by draging, clicking is for selecting the slot.

please help!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnDrop doesn't work when I drop the item on my dragged slot;
« Reply #1 on: January 28, 2014, 09:35:43 AM »
Without knowing what you changed in your customized UIItemSlot, how can I tell you why it's not working for you? The example provided with NGUI lets this happen automatically. I suggest you having a look at it and seeing what you did to change that logic.

minileen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: OnDrop doesn't work when I drop the item on my dragged slot;
« Reply #2 on: January 28, 2014, 09:07:44 PM »
on this subject ,the original system doesn't work neither.

i tried the Example X scene with the orc in it:

i dragged one item out,hold my mouse button,and i want to put it back, when i release the mousebutton i'v been holding, the item didn't drop.
i have to click again,then it drop.

let's say,if i have an inventory with only one slot. and a item in it,after i drag the item out i will never put it back by ondrop,but with onclick.
as if the ondrop event won't trigger if you have something dragged out from that slot;
I tried "debug.log" and it is true; :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnDrop doesn't work when I drop the item on my dragged slot;
« Reply #3 on: January 29, 2014, 09:51:17 AM »
The inventory system isn't coded to return the object to where it was. It also doesn't use the drag & drop functionality. Instead it has a custom cursor that changes based on what you're "carrying".

Instead of looking at the inventory, have a look at the Drag & Drop example that comes with NGUI or watch the NGUI 3.0.7 Tutorial video. Both show items returning to their original spot.

In particular, have a look at UIDragDropItem line 203:
  1.                                 // No valid container under the mouse -- revert the item's parent
  2.                                 mTrans.parent = mParent;