Author Topic: UICamera.isDragging bug?  (Read 8573 times)

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
UICamera.isDragging bug?
« on: September 02, 2013, 10:10:25 AM »
UICamera.isDragging is defined in the documentation as "Set to 'true' just before OnDrag-related events are sent (this includes OnPress events that resulted from dragging)."

From my testing and code inspection, there appears to be a case where this is not accurate. When a drag starts and ends over the same object, isDragging is false when OnPress(false) occurs on that object after the drag.

isDragging is true when OnPress(false) occurs on an object that is not the same object as the drag was started on, and during all OnDrag events.
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera.isDragging bug?
« Reply #1 on: September 02, 2013, 05:52:05 PM »
What are you using this for? As I recall isDragging was used internally, and was mainly for things like draggable panels.

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
Re: UICamera.isDragging bug?
« Reply #2 on: September 02, 2013, 08:23:56 PM »
Thank you for the timely reply on Labor Day!

isDragging is public and I'm using it per the documentation to determine whether the OnPress(false) is occurring at the conclusion of a drag event. If it is, then I don't want my context menus (Contextual) to open up. As it is now, they will open if OnPress(true) and OnPress(false) occur in sequence over the same object, even if it was a drag that was going on between the two events.

As Ngui is the senior citizen here and Contextual is derived, the issue could clearly be put on Contextual, but then they would do the same thing I did, test isDragging the way I'm attempting per the documentation.

I don't mean to raise an issue between Ngui and the derived Contextual, but the Ngui documentation is clear on what the public isDragging will indicate as a public field including OnPress events as a result of dragging. I inspected the code to make sure I knew what I was saying before I said it, although admittedly, I could have missed something.

I became aware of isDragging from your answers on another thread when someone was looking to create their own dragging boolean and you said, "no need, use isDragging." or words to that effect.

I honestly thought I had uncovered a small bug. :-\

btw, saw your Unite presentation. Looking forward to Ngui 3.0 in Unity!
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera.isDragging bug?
« Reply #3 on: September 04, 2013, 04:54:20 AM »
Looking at how it's used in UICamera:
  1.                         if (!stickyPress && !unpressed && currentTouch.pressStarted && currentTouch.pressed != hoveredObject)
  2.                         {
  3.                                 isDragging = true;
  4.                                 Notify(currentTouch.pressed, "OnPress", false);
  5.                                 currentTouch.pressed = hoveredObject;
  6.                                 Notify(currentTouch.pressed, "OnPress", true);
  7.                                 isDragging = false;
  8.                         }
It's evident that this flag is only set to 'true' if the object you dropped the item on is different from the object you started the drag process on.

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
Re: UICamera.isDragging bug?
« Reply #4 on: September 04, 2013, 05:10:25 AM »
Yes, that was my reading of the code too. The reason I thought it was a bug/oversight is that the OnPress(false) event (over the same object) is "a result of dragging" too, not just the one that occurs when the object is different.

As you are the man here, I'll of course go whichever way you choose to call this. Making my own boolean isn't too difficult. :-)
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.