tags:

views:

1557

answers:

5

What is the time limit for two taps to be considered a double-tap, on the iPhone OS?

// Edit: Why is this important?

In order to handle single-tap and double-tap differently, Apple's guide says to do performSelector...afterDelay with some 'reasonable' interval on first tap (and cancel it later if the second tap is detected).

The problem is that if the interval is too short (0.1), the single tap action will be performed even when double-tapping (if relying only on tapCount, that is). If it's too long (0.8), the user will be waiting unnecessarily for the single-tap to be recognized, when there is no possibility for a double-tap.

It has to be exactly the correct number, in order to work optimally, but definitely not smaller, or there's a chance for bugs (simultaneous single-tap and double-tap).

A: 

On windows (and I'd guess most other systems) this is a system settings so you should look for an API that returns this. (the term "double click" might get more hits from Google)

BCS
Check the tag ;-) this question is probably aimed to iphone, and not windows ;-)
Pascal MARTIN
(BTW : I hate people who downvote without telling why... I'm not the one who downvoted this answer, despite my previous comment)
Pascal MARTIN
OK :-) (my second comment is still true ^^ )
Pascal MARTIN
It was tagged iPhone from the beginning. Still, don't downvote people for mistakes, come on now :/ I'll state the platform in the question explicitly, to make it more obvious.
Jaka Jančar
+1  A: 

I don't believe there is a default time-limit - it's whatever "feels" right when you try it out. Apple has an example here, where they don't specify a specific time either.

Itay
There must be a limit, since UITouch's tapCount doesn't increase if the clicks are a second apart, yet it does if they are close together.
Jaka Jančar
+2  A: 

On Developer Forums on developer.apple.com, an Apple developer said:

  • There's no constant time interval, but the system-wide definition is implicit today in the tapCount property of UITouch.
  • There is not default value for this delay and for touch-and-hold delay.
  • SpringBoard has the value hardcoded.

I have submitted this to Apple as bug 68405.

Jaka Jančar
+2  A: 

"- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

UITouch *touch = [touches anyObject];

NSUInteger tapCount = [touch tapCount];

switch (tapCount) {
    case 1:
        [self performSelector:@selector(singleTapMethod) withObject:nil afterDelay:.4];
        break;
    case 2:
        [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(singleTapMethod) object:nil];
        [self performSelector:@selector(doubleTapMethod) withObject:nil afterDelay:.4];
        break;
    case 3:
        [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(doubleTapMethod) object:nil];
        [self performSelector:@selector(tripleTapMethod) withObject:nil afterDelay:.4];
        break;
    case 4:
        [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(tripleTapMethod) object:nil];
        [self quadrupleTap];
        break;
    default:
        break;
}

} @end

for me this code is working prefectly fine.... :) the last post was around august 15 09.... but i was going through the same problem so thought to share the solution i found....

yunas
+2  A: 

In the Apple provided example of the iPhone Application Programming Guide: Event Handling (mentioned by user Italy) a delay of 0.3 is used:

[self performSelector:@selector(handleSingleTap:) withObject:touchLoc afterDelay:0.3];
Travis