Support => NGUI 3 Support => Topic started by: soofaloofa on June 04, 2012, 06:09:25 PM
Title: BUG: OnDoubleClick not firing in iOS
Post by: soofaloofa 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).
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: soofaloofa on June 11, 2012, 08:01:56 PM
Anything on this issue?
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ENAY 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.
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: PhilipC 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.
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ijneb11 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?
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ArenMook on June 21, 2012, 05:08:11 AM
UICamera.touchClickThreshold
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ijneb11 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?
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ArenMook 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.
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: Gregzo 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).
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ixgaming 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 ());
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;
?
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: soofaloofa on July 11, 2012, 09:20:49 PM
I am still having the same issue and haven't found a solution yet.
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ArenMook 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:
Can you put a Debug.Log in there to see where it gets triggered from?
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ixgaming 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 (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);
I only want to raise the OnDoubleClick event instead of the OnClick event. (this one works).
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ixgaming 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;
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?
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ArenMook on July 12, 2012, 04:57:05 PM
Ah... I'm guessing I know what's wrong. The taps have different touch IDs. First time you tap it may give you 1, next time -- 2, etc. Since it's a different ID, it's treated as a different touch, so the "clickTime" value is not what you'd expect.
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ixgaming on July 12, 2012, 05:15:53 PM
Here is a "bad" way to process a doubleClick until that bug is fixed :
In the OnClick() (raised with UICamera) function i've simply added the following code:
public class buttonController : MonoBehaviour { public float clickTime;
ArenMook, Yes your analysis seems ok. Could you try to correct the UICamera to allow a clean version of the double click ?
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ArenMook on July 12, 2012, 07:13:59 PM
Your approach is actually how I had it done before adding OnDoubleClick to begin with. I'll see if I can figure out a way to do it elegantly in the UICamera.
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ixgaming on July 13, 2012, 02:34:43 AM
Thanks ArenMook ! ;)
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: IQpierce on January 16, 2013, 03:55:14 PM
I'm running into this bug and I'd rather not use the workaround described. Was a fix for this ever completed and made available?
Is there a suggested code patch to fix it? Or has there been a fix put into a recent version of NGUI?
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: YD4k on January 17, 2013, 04:08:12 AM
and it works for me both on android & iOS devices.[/code]
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ArenMook on January 17, 2013, 09:41:13 PM
I will add that to the local repository and see how it behaves. If there are no adverse effects, you'll see this change in the next update.
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: basil_11 on January 27, 2013, 08:56:11 PM
Hi,
Same problem here! doubeClick is not triggered in iPad, but works in editor
anyone who solved this problem?
pls. Share!!!!! thank you so much.. hoping for a reply
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: basil_11 on January 27, 2013, 09:12:40 PM
Hi, Anyone solved this problem?
pls. share the solution, thank you
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ArenMook on January 28, 2013, 02:28:53 PM
Update your NGUI.
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: filippopotamus on March 06, 2013, 09:03:59 PM
Is this fixed? Because I am running the version 2.3.4 and I am getting the same issue. It works fine on editor, but doesn't on iPad. I played around with Touch/Mouse Drag/Cick Thresholds from small to big values and nothing. :( I tried the solution YD4k posted and it worked, however, some of my other buttons stop working properly after that. For example, I have a fire button, which makes the player fire a bullet, but he is only supposed to fire once a second, and if I double tap that button with YD4k solution, it fires twice rapidly.
Title: Re: BUG: OnDoubleClick not firing in iOS
Post by: ArenMook on March 07, 2013, 01:44:47 AM
Double click/tap works fine as far as I know. I'm using it in a game I'm working on to ping objects on double-click. Works as expected.