Author Topic: BUG: OnDoubleClick not firing in iOS  (Read 13055 times)

soofaloofa

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
BUG: OnDoubleClick not firing in iOS
« on: June 04, 2012, 06:09:25 PM »
In code I am listening for an OnDoubleClick event but it does not fire when on iOS (iPad 2).
« Last Edit: June 04, 2012, 06:21:38 PM by soofaloofa »

soofaloofa

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
Re: BUG: OnDoubleClick not firing in iOS
« Reply #1 on: June 11, 2012, 08:01:56 PM »
Anything on this issue?

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: BUG: OnDoubleClick not firing in iOS
« Reply #2 on: June 11, 2012, 09:38:14 PM »
Does it work on your other iOS devices?

If other people aren't experiencing this problem. You might find it useful to create a test program that replicates the problem and then post it here.

PS, the author of this site is on holiday for a week.

PhilipC

  • Guest
Re: BUG: OnDoubleClick not firing in iOS
« Reply #3 on: June 12, 2012, 10:09:08 AM »
It is possible that your not getting the doubleclick as the change delta is to great. i.e. you moved your finger too much during one of the touches so it didnt count as being a touch.

ijneb11

  • Guest
Re: BUG: OnDoubleClick not firing in iOS
« Reply #4 on: June 21, 2012, 02:35:56 AM »
I have the same problem on iOS and Android. If this comes for the change delta, then it must be really too low. Is there any way to change that?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: BUG: OnDoubleClick not firing in iOS
« Reply #5 on: June 21, 2012, 05:08:11 AM »
UICamera.touchClickThreshold

ijneb11

  • Guest
Re: BUG: OnDoubleClick not firing in iOS
« Reply #6 on: July 05, 2012, 10:01:46 AM »
Hi again.

So, I finally came back on this issue in my code.
I tried changing the threshold and this changed nothing as the function which must be called by the UIButtonMessage on the DoubleClick event is never called.

So, as this gameobject had another UIButtonMessage script for Click event, I removed this last one (which works fine) thinking that it may interfer (does it?) with the DoubleClick event. But I still don't have my DoubleClick function called.

Does anybody has/had the same problem?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: BUG: OnDoubleClick not firing in iOS
« Reply #7 on: July 05, 2012, 06:18:31 PM »
They shouldn't interfear. Each one receives events separately. The double click event is sent in UICamera, line 934. It only happens if you clicked twice within 1/4th of a second. Could you be tapping too slowly perhaps? Try modifying 0.25f on line 932 to something higher.

Gregzo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 64
    • View Profile
Re: BUG: OnDoubleClick not firing in iOS
« Reply #8 on: July 10, 2012, 03:10:49 AM »
I'm having the exact same problem.

Touch threshold set to 40, works fine in the editor but not on the device: OnDoubleClick is simply not triggered.

Coding my own for now, but there's definitely something fishy here : all other touch events are fine!

Tapping speed is not the issue either : .25s is quite a long threshold, I'm tapping at .10 (logged).

ixgaming

  • Guest
Re: BUG: OnDoubleClick not firing in iOS
« Reply #9 on: July 11, 2012, 06:03:31 PM »
Hi,


I am new here but i am having the same problem with OnDoubleClick :
I have added some log in the UICamera script trying to understand what is the problem :
 
in fact  on the iPhone, the Bold value currentTouch.clickTime is always == 0 .
But the assignation with the line  Italic Bold underlined is well done ...

It seems ClickTime is reseted on iphone while it is not on the Editor....

So because clicktime is always 0, this conditions is never true :
if (currentTouch.clickTime + 0.25f > time) {
//
}

I do not understand why. Any idea ?

Starting line 909 :
   // If the button/touch was released on the same object, consider it a click and select it
            if (currentTouch.pressed == currentTouch.current) {
               if (currentTouch.pressed != mSel) {
                  mSel = currentTouch.pressed;
                  currentTouch.pressed.SendMessage ("OnSelect", true, SendMessageOptions.DontRequireReceiver);
               } else {
                  mSel = currentTouch.pressed;
               }

               // If the touch should consider clicks, send out an OnClick notification
               if (currentTouch.clickNotification != ClickNotification.None) {
                  float time = Time.realtimeSinceStartup;
                  Debug.Log ("time :" + time.ToString ());
               
                  currentTouch.pressed.SendMessage ("OnClick", SendMessageOptions.DontRequireReceiver);
                  
                  Debug.Log ("currentTouch.clickTime + 0.25f =" + (currentTouch.clickTime + 0.25f));
                  Debug.Log ("currentTouch.clickTime =" + currentTouch.clickTime.ToString ());
                     
                  if (currentTouch.clickTime + 0.25f > time) {
                     currentTouch.pressed.SendMessage ("OnDoubleClick", SendMessageOptions.DontRequireReceiver);
                     Debug.Log ("DblClick");
                  }
                  currentTouch.clickTime = time;
                  Debug.Log ("currentTouch.clickTime =" + time.ToString ());      
               }
            } else { // The button/touch was released on a different object
               // Send a drop notification (for drag & drop)
               if (currentTouch.current != null)
                  currentTouch.current.SendMessage ("OnDrop", currentTouch.pressed, SendMessageOptions.DontRequireReceiver);
            }
         }



Perhaps the problem comes from the block
void ProcessTouches ()
   {
}

at line 793 with
// If the touch has ended, remove it from the list
         if (unpressed) RemoveTouch(currentTouchID);
         currentTouch = null;

?
« Last Edit: July 11, 2012, 06:09:56 PM by ixgaming »

soofaloofa

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
Re: BUG: OnDoubleClick not firing in iOS
« Reply #10 on: July 11, 2012, 09:20:49 PM »
I am still having the same issue and haven't found a solution yet.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: BUG: OnDoubleClick not firing in iOS
« Reply #11 on: July 12, 2012, 01:38:59 AM »
It's made more complicated by the fact that I'm using 2.1.0 here, and this class is a fair bit different, so the line numbers don't match at all... but... this is the only place where the click notification gets set to "none" if it's not "none" already:
  1. if (currentTouch.totalDelta.magnitude > threshold)
  2. {
  3.         currentTouch.clickNotification = ClickNotification.None;
  4. }
Can you put a Debug.Log in there to see where it gets triggered from?

ixgaming

  • Guest
Re: BUG: OnDoubleClick not firing in iOS
« Reply #12 on: July 12, 2012, 03:22:04 PM »
Hi ArenMook,

I've added a Debug.Log() but it is never raised with a or Double  Tap on the iPhone :

   else if (currentTouch.clickNotification == ClickNotification.BasedOnDelta)
         {
            // If the notification is based on delta and the delta gets exceeded, disable the notification
            float threshold = (currentTouch == mMouse[0]) ? mouseClickThreshold : Mathf.Max(touchClickThreshold, Screen.height * 0.1f);

            if (currentTouch.totalDelta.magnitude > threshold)
            {
               currentTouch.clickNotification = ClickNotification.None;
               Debug.Log("currentTouch.clickNotification = ClickNotification.None");
            }
         }
      }

      // Send out the unpress message
      if (unpressed)


so I have put a Touch Click Threshold of 400 but, "DoubleClick" is never raised and the aboge Debug.Log() too.

?
« Last Edit: July 12, 2012, 03:34:39 PM by ixgaming »

ixgaming

  • Guest
Re: BUG: OnDoubleClick not firing in iOS
« Reply #13 on: July 12, 2012, 03:57:59 PM »
I have added some other Debug.Log :

if (pressed)
      {
         Debug.Log ("Pressed 1");
         if (mTooltip != null) ShowTooltip(false);
         currentTouch.pressed = currentTouch.current;
         currentTouch.clickNotification = ClickNotification.Always;
         currentTouch.totalDelta = Vector2.zero;
         if (currentTouch.pressed != null) currentTouch.pressed.SendMessage("OnPress", true, SendMessageOptions.DontRequireReceiver);

         // Clear the selection
         if (currentTouch.pressed != mSel)
         {
            if (mTooltip != null) ShowTooltip(false);
            selectedObject = null;
         }
      }
      else if (currentTouch.pressed != null && currentTouch.delta.magnitude != 0f)
      {
         Debug.Log ("Pressed 2");
         if (mTooltip != null) ShowTooltip(false);
         currentTouch.totalDelta += currentTouch.delta;

         bool isDisabled = (currentTouch.clickNotification == ClickNotification.None);
         currentTouch.pressed.SendMessage("OnDrag", currentTouch.delta, SendMessageOptions.DontRequireReceiver);

         if (isDisabled)
         {
            Debug.Log ("Pressed 3");
            // If the notification status has already been disabled, keep it as such
            currentTouch.clickNotification = ClickNotification.None;
         }
         else if (currentTouch.clickNotification == ClickNotification.BasedOnDelta)
         {
            Debug.Log ("Pressed 4");
            // If the notification is based on delta and the delta gets exceeded, disable the notification
            float threshold = (currentTouch == mMouse[0]) ? mouseClickThreshold : Mathf.Max(touchClickThreshold, Screen.height * 0.1f);

            if (currentTouch.totalDelta.magnitude > threshold)
            {
               Debug.Log ("Pressed 5");
               currentTouch.clickNotification = ClickNotification.None;
            }
         }



"Pressed 5" never appears on the iPhone.

I only want to raise the OnDoubleClick event instead of the OnClick event. (this one works).

ixgaming

  • Guest
Re: BUG: OnDoubleClick not firing in iOS
« Reply #14 on: July 12, 2012, 04:33:20 PM »
Well,

I've added this :


if (unpressed)
      {
         Debug.Log ("Unpressed 1");
         if (mTooltip != null) ShowTooltip(false);

         if (currentTouch.pressed != null)
         {
            currentTouch.pressed.SendMessage("OnPress", false, SendMessageOptions.DontRequireReceiver);
            Debug.Log ("Unpressed 2");
            // Send a hover message to the object, but don't add it to the list of hovered items as it's already present
            // This happens when the mouse is released over the same button it was pressed on, and since it already had
            // its 'OnHover' event, it never got Highlight(false), so we simply re-notify it so it can update the visible state.
            if (useMouse && currentTouch.pressed == mHover) currentTouch.pressed.SendMessage("OnHover", true, SendMessageOptions.DontRequireReceiver);

            // If the button/touch was released on the same object, consider it a click and select it
            if (currentTouch.pressed == currentTouch.current)
            {
               Debug.Log ("Unpressed 3");
               if (currentTouch.pressed != mSel)
               {
                  mSel = currentTouch.pressed;
                  currentTouch.pressed.SendMessage("OnSelect", true, SendMessageOptions.DontRequireReceiver);
               }
               else
               {
                  mSel = currentTouch.pressed;
               }

               // If the touch should consider clicks, send out an OnClick notification
               if (currentTouch.clickNotification != ClickNotification.None)
               {
                  Debug.Log ("Unpressed 4");
                  float time = Time.realtimeSinceStartup;

                  currentTouch.pressed.SendMessage("OnClick", SendMessageOptions.DontRequireReceiver);

                  if (currentTouch.clickTime + 0.25f > time)
                  {
                     Debug.Log ("Unpressed 5");
                     currentTouch.pressed.SendMessage("OnDoubleClick", SendMessageOptions.DontRequireReceiver);
                  }
                  currentTouch.clickTime = time;
               }
            }
            else // The button/touch was released on a different object
            {
               Debug.Log ("Unpressed 6");
               // Send a drop notification (for drag & drop)
               if (currentTouch.current != null) currentTouch.current.SendMessage("OnDrop", currentTouch.pressed, SendMessageOptions.DontRequireReceiver);
            }
         }
         currentTouch.pressed = null;
      }


When i make a double tap on an item in a UIGrid I see "Unpressed 1", "Unpressed 2", "Unpressed 3" or "Unpressed 4" but never "Unpressed 5" which should raise OnDoubleClick.

Any idea?
« Last Edit: July 12, 2012, 04:36:30 PM by ixgaming »