Author Topic: Does UIDragDropItem need a "dragging" flag?  (Read 4661 times)

MrTact

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 32
    • View Profile
Does UIDragDropItem need a "dragging" flag?
« on: February 18, 2014, 01:26:54 PM »
I am currently implementing drag and drop for our UI, and I've run into a problem. The restriction-checking block in UIDragItem.OnDragStart doesn't seem to set any kind of state that I can check, and I am getting OnDragMove notifications in my UIDragItem subclass even if the drag is along a restricted axis. Is there some obvious way to get at this information without duplicating the delta check?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Does UIDragDropItem need a "dragging" flag?
« Reply #1 on: February 19, 2014, 12:06:08 PM »
If you need a flag, I would suggest driving a custom class from from UIDragDropitem and overwriting OnDragDropStart to set it, and OnDragDropRelease to remove it. OnDragMove notifications don't start until the restriction conditions are met (which you can see in UIDragDropItem.OnDragStart).

MrTact

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 32
    • View Profile
Re: Does UIDragDropItem need a "dragging" flag?
« Reply #2 on: February 19, 2014, 07:29:06 PM »
Ah, I misspoke -- I was originally handling dragging one object on top of another by sending a message to the drop target in OnDragMove. Then I realized that I was duplicating functionality that already existed in UICamera and switched it to use OnDragOver and OnDragOut. The actual problem was that I was still getting drag over and out notification even if I dragged along a restricted axis.

What I did not realize (until I looked at it just now) is that this is probably by design. The camera sends these without regard to UIDragDropItem settings, because I expect that this is useful in other areas (such as handling gestures).

Knowing that is the case, I did in fact wedge a flag in there, but as you recommended, it's in user code where it belongs.