Author Topic: Drag & Drop Question  (Read 2191 times)

ahaykal

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Drag & Drop Question
« on: May 23, 2015, 05:02:37 AM »
Hello Nguiers,

I would like to ask a question concerning drag and drop.
My issue is the following:

I have 2 containers/grids that I am moving items between them. Everything is working fine but I am wondering if it is possible to do this:

Right now, when I click and drag I move the sprite and on releasing the object it gets sorted in the grid.
Is it possible to sort it while dragging and not when the dragging ends?
I was wondering if anyone could help me with this matter !

Thank you for your help!
« Last Edit: May 23, 2015, 05:07:43 AM by ahaykal »

ahaykal

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Drag & Drop Question
« Reply #1 on: May 25, 2015, 02:15:04 AM »
Bump?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag & Drop Question
« Reply #2 on: May 26, 2015, 02:56:35 PM »
Sure, you can do what you want. Just listen to OnDrag events (or OnDragOver if you want to be more efficient) and call the grid's sorting.

ahaykal

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Drag & Drop Question
« Reply #3 on: May 27, 2015, 03:15:53 AM »
The problem with that is the dragged object isn't reparented, so calling the grid sort isn't working.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag & Drop Question
« Reply #4 on: June 01, 2015, 07:40:29 PM »
You can have a dummy object get created when you start the drag operation, with this dummy object parented to the grid. Adjust its position when you drag and call the grid's Reposition() -- it will act as you expect. Destroy this dummy game object when you stop the drag operation.