Re: Knowing mouse pressed time?
site_archiver@lists.apple.com Delivered-To: cocoa-dev@lists.apple.com Am 31.12.2009 um 00:09 Uhr schrieb Ken Thomases: (Typed in Mail.app) Andreas _______________________________________________ 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/site_archiver%40lists.apple... There is no mouse-up event. He wants to present a menu if there's been X time since the mouse-down even when _no other events have arrived since then_. There's no getting around using a timer of some sort. That's a case for -performSelector:withObject:afterDelay: (which obviously uses a timer of some sort) - (void)mouseDown:(NSEvent *)theEvent { // send openMenu: to self after 0.8 seconds [self performSelector:@selector(openMenu:) withObject:nil afterDelay: 0.8]; } - (void)mouseUp:(NSEvent *)theEvent { // user released mouse button - cancel previous perform request [NSObject cancelPreviousPerformRequestWithTarget:self selector:@selector(openMenu:) object:nil]; } This email sent to site_archiver@lists.apple.com
participants (1)
-
Andreas Mayer