On Sat, 05 Jun 2010 21:34:48 -0700, Matt Neuburg <m...@tidbits.com> said: >On Fri, 4 Jun 2010 21:16:50 -0500, Alejandro Marcos Arag?n ><alejandro.ara...@gmail.com> 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 = m...@tidbits.com, <http://www.tidbits.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com