Re: Knowing mouse pressed time?
site_archiver@lists.apple.com Delivered-To: cocoa-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:mime-version :content-type:from:in-reply-to:date:cc:content-transfer-encoding :message-id:references:to:x-mailer; bh=NJ7frWy/OMOmopsgfYDOqw5sdjcGRqZFcOlTfZ9gP5E=; b=Qgh46mc8xEO9QnyTIsVBnErDYC3p6AB3eGYdE7Jsoasal8UjPP2GJZAcxUjLmjlkFR 59WbRvg3K3ZWpeJMNX48F/tfaQtOD8Fmdqs0Sjx/FYGJKUjx0iwMpUXf45+IX1bZuv0X QYdEWsA2A23Cr1QA+8cOjkxstnPc+p2O5oosk= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=ru21c9ncJXAfoe6626I4FGf/BGgxrx95hq3CrwUviFmhiTbHdoFiztGDjJGtgRQ5dk Wk4MfIns+uFoaQPx6DkRMH4yGNlpihBnPV0wtl+epNQQbGLZhGivSQWE80XpU60oNw94 D8XIXyONs6ED65bNXcG4q2uw3i3Ol5hX0B2/E= 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 (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... This email sent to site_archiver@lists.apple.com
participants (1)
-
Gustavo Pizano