Re: Knowing mouse pressed time?
Re: Knowing mouse pressed time?
- Subject: Re: Knowing mouse pressed time?
- From: "Henry McGilton (Boulevardier)" <email@hidden>
- Date: Wed, 30 Dec 2009 13:59:09 -0800
On Dec 30, 2009, at 11:43 AM, Gustavo Pizano wrote:
> Henry hi.
> You mean with the NEEvent method that returns the timestamp?... I was trying that also, and as far as I understood its the timestamp between the App startup and the event... so I dunno how this might help me... maybe I misunderstood the API doc?
>
> To clarify the original question, what I want to achieve is something similar to 10.6 dock, when you press the mouse on an icon, after a second or so, the menu appears. I dunno if this is what you understood.. I hope its better explained now. :P
Sorry I did not intend the thread to get into a deep discussion on the relative merits
of how to do things, nor, as I said, to invalidate Fabian's idea.
I meant that rather than setting a timer and implementing a callback method and
remembering to invalidate the timer, and so on and so on, you can do something
like this (which took less time to implement than the time required to explain it . . . ):
- (void)mouseDown:(NSEvent *)theEvent
{
NSLog(@"mouseDown");
[self setStartStamp: [theEvent timestamp]];
}
- (void)mouseUp:(NSEvent *)theEvent
{
NSLog(@"mouseUp");
NSTimeInterval endStamp = [theEvent timestamp];
NSLog(@"time difference = %.2f", endStamp - [self startStamp]);
}
where startStamp is an instance variable that records the timestamp on mouse down.
Then on mouse up, you grab the timestamp of the mouseUp's event and take the difference
between the two timestamps . .
Yes, the event's timestamp is the time since system startup (which I interpret to mean the time
since last reboot), but that doesn't really matter --- all you're concerned about is the
difference in time between mouse down and mouse up . . .
Interesting that I just recently implemented something like this for the iphone for similar
reasons, namely, to decide whether to show the Cut/Copy/Paste menu . . .
Hope that clarifies what I meant.
Cheers,
. . . . . . . . Henry
=================================================
iPhone App Development and Developer Education . . .
Visit www.nonatomic-retain.com
Mac OSX Application Development, Plus a Great Deal More . . .
Visit www.trilithon.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