Re: Knowing mouse pressed time?
Re: Knowing mouse pressed time?
- Subject: Re: Knowing mouse pressed time?
- From: Gustavo Pizano <email@hidden>
- Date: Thu, 31 Dec 2009 10:43:53 +0100
Yep Ken is right.
I want to present the menu after a dt has passed with the mouse pressed, so the mouseUp will never be called until (the menu is presented, which in this case the user will release the mouse button, or when the user depresses the button before the required time).
So Henry's Idea clarifies me how to use the timestamp method, and give some ideas how to implement another stuff I need to in the future.
Thanks for the reply. :)
Gustavo
On Dec 31, 2009, at 12:09 AM, Ken Thomases wrote:
> On Dec 30, 2009, at 3:59 PM, Henry McGilton (Boulevardier) wrote:
>
>> 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 . .
>
> 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.
>
> Cheers,
> Ken
>
_______________________________________________
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