Author Topic: How can I manually cancel drag of UIDragDropItem?  (Read 3434 times)

Ging

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
How can I manually cancel drag of UIDragDropItem?
« on: August 21, 2014, 07:05:48 AM »
Clearing following things will do nothing
  1. UICamera.currentTouch.dragStarted = false;
  2. UICamera.currentTouch.pressed.SendMessage("OnPress", false);
  3. UICamera.currentTouch.pressed.SendMessage("OnHover", false);
  4. UICamera.currentTouch.pressed = null;
  5. UICamera.currentTouch.dragged = null;
  6. UICamera.currentTouch.current = null;
  7. UICamera.currentTouch = null;

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How can I manually cancel drag of UIDragDropItem?
« Reply #1 on: August 22, 2014, 03:37:33 AM »
I recently had to do this for Windward myself (like literally a few days ago). UIDragDropItem was expanded in the Pro repository. Currently you can do StopDragging(target) on it, passing it the object you want it to be released on (or 'null' for nothing).

If you have Pro, you can grab the latest and use it. If you don't have Pro, you will find it in the next update.

Ging

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: How can I manually cancel drag of UIDragDropItem?
« Reply #2 on: August 22, 2014, 05:35:33 AM »
Thanks a lot ^)

toqueteos

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: How can I manually cancel drag of UIDragDropItem?
« Reply #3 on: November 24, 2014, 04:51:35 PM »
I'm a bit late to the party but it's super related.

Is there a "builtin" way of reverting a drag? By reverting I mean doing just the same as StopDragging but also ignore the UIDragDropContainer it may be sitting on and get back to wherever the drag started.
« Last Edit: November 24, 2014, 05:09:13 PM by toqueteos »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How can I manually cancel drag of UIDragDropItem?
« Reply #4 on: November 25, 2014, 01:36:55 AM »
ExampleDragDropItem has the code inside that performs additional validation inside. You can always cancel the drag operation, returning the item back to its spot.

toqueteos

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: How can I manually cancel drag of UIDragDropItem?
« Reply #5 on: November 25, 2014, 06:46:37 AM »
ExampleDragDropItem has the code inside that performs additional validation inside. You can always cancel the drag operation, returning the item back to its spot.
Yeah I saw that but it still calls base.OnDragDropRelease which is the one causing problems.
Should I copy the method's contents removing the UIDragDropContainer part to be good to go?
Seems the only way to cancel the operation as if no DropContainer wast here.
« Last Edit: November 25, 2014, 07:07:58 AM by toqueteos »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How can I manually cancel drag of UIDragDropItem?
« Reply #6 on: November 26, 2014, 08:10:14 PM »
ExampleDragDropItem is a custom script. Write your own custom script that won't be calling base.OnDragDropRelease.