Knowing mouse pressed time?
Knowing mouse pressed time?
- Subject: Knowing mouse pressed time?
- From: Gustavo Pizano <email@hidden>
- Date: Wed, 30 Dec 2009 11:18:07 +0100
Hello.
I want to show a custom menu when the left click its being press for about 1 second on some of my components.. I have being searching and found a apple example where the use the
+ (void)startPeriodicEventsAfterDelay:(NSTimeInterval)delaySecondswithPeriod:(NSTimeInterval)periodSeconds
and the stopPeriodicEvents class methods. I tried implementing something like:
BOOL timerOn = YES;
NSPoint mouseLoc;
NSLog(@"before loop");
NSUInteger eventMask = NSLeftMouseDownMask| NSLeftMouseUpMask | NSPeriodicMask;
while ((theEvent = [[self window] nextEventMatchingMask:eventMask])) {
NSLog(@"onLoop");
switch ([theEvent type]) {
case NSLeftMouseUp:
NSLog(@"up");
timerOn = NO;
[NSEvent stopPeriodicEvents];
break;
case NSLeftMouseDown:
NSLog(@"down");
[NSEvent startPeriodicEventsAfterDelay:0.1 withPeriod:0.1];
break;
default:
break;
}
}
But of course its completely wrong, it never go out from the loop... I tried a different approach usign a NSTimer, but found myself going nowhere also...
Can somebody give me some advice, or where can I find info?, i have been looking around but hadn't found something... I know this should have been asked already, so there must be a way to do this.
Thanks in advance .. and happy new year.
Gustavo
_______________________________________________
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