Re: Knowing mouse pressed time?
Re: Knowing mouse pressed time?
- Subject: Re: Knowing mouse pressed time?
- From: Andreas Mayer <email@hidden>
- Date: Thu, 31 Dec 2009 14:25:48 +0100
Am 31.12.2009 um 00:09 Uhr schrieb Ken Thomases:
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];
}
(Typed in Mail.app)
Andreas
_______________________________________________
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