• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: detecting touch and hold vs touch in UIButton
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: detecting touch and hold vs touch in UIButton


  • Subject: Re: detecting touch and hold vs touch in UIButton
  • From: Matt Neuburg <email@hidden>
  • Date: Sun, 06 Jun 2010 07:35:47 -0700
  • Thread-topic: detecting touch and hold vs touch in UIButton

On Sat, 05 Jun 2010 21:34:48 -0700, Matt Neuburg <email@hidden> said:
>On Fri, 4 Jun 2010 21:16:50 -0500, Alejandro Marcos Arag?n
><email@hidden> said:
>>I've been trying to detect touch and hold vs touch on a subclass of UIButton.
>
>I think you want to imitate Listing 3-3 of Event Handling in the iPhone
>Application Programming Guide, handling the touches yourself. m.

Okay, forget that answer. :) If the difference between touch and
touch-and-hold is just a matter of how long the time is between the touch
down and the touch up, then all you have to do is measure that time:

- (void) userDidTouchDown: (id) sender event: (UIEvent*) e {
    downtime = [e timestamp]; // downtime is an ivar or global
}

- (void) userDidTouchUp: (id) sender event: (UIEvent*) e {
    double diff = [e timestamp] - downtime;
    if (diff < 0.2) NSLog(@"tap");
    else NSLog(@"tap and hold");
}

Obviously Touch Down is targeted at userDidTouchDown:. I think you might
want to target both Touch Up Inside and Touch Up Outside at userDidTouchUp:.

If you mean something more complex and profound by the difference between
touch and touch-and-hold, you can probably figure it out from the UIEvent,
so you'd do some more complex and profound form of event tracking here.

Anyway, I apologize for being hasty and not very clear before. What I was
really trying to say was that all your addition and removal of target-action
pairs seems unnecessary.

m.

--
matt neuburg, phd = email@hidden, <http://www.tidbits.com

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: detecting touch and hold vs touch in UIButton
      • From: Alejandro Marcos Aragón <email@hidden>
  • Prev by Date: Re: [iPhone] Preprocessing events sent to UITableView
  • Next by Date: Re: [iPhone] Preprocessing events sent to UITableView
  • Previous by thread: Re: detecting touch and hold vs touch in UIButton
  • Next by thread: Re: detecting touch and hold vs touch in UIButton
  • Index(es):
    • Date
    • Thread