Re: Knowing mouse pressed time?

2009-12-31 Thread Gustavo Pizano
VERY INTERESTING!!! :D G. On Dec 31, 2009, at 2:25 PM, Andreas Mayer wrote: > > 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_.

Re: Knowing mouse pressed time?

2009-12-31 Thread Andreas Mayer
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 -performSelec

Re: Knowing mouse pressed time?

2009-12-31 Thread Gustavo Pizano
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 Id

Re: Knowing mouse pressed time?

2009-12-30 Thread Ken Thomases
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 requi

Re: Knowing mouse pressed time?

2009-12-30 Thread Henry McGilton (Boulevardier)
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 > mi

Re: Knowing mouse pressed time?

2009-12-30 Thread Gustavo Pizano
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

Re: Knowing mouse pressed time?

2009-12-30 Thread Henry McGilton (Boulevardier)
On Dec 30, 2009, at 2:53 AM, slasktrattena...@gmail.com wrote: > Simple. Start a timer on mouse down, invalidate it on mouse up. > Something like this (written in mail): > > NSTimer *timer; > > -(void)mouseDown:(NSEvent*)ev > { >timer=[[[NSTimer alloc] blah ...] retain]; > } > > -(void)mou

Re: Knowing mouse pressed time?

2009-12-30 Thread Gustavo Pizano
AHAH OK got it its one of the parameters when initializing the timer... ok... sorry for the noob question... :D On Dec 30, 2009, at 12:47 PM, slasktrattena...@gmail.com wrote: > The performholdAction is your timer's fire method. You set the timer > to fire after one second. If the mouse button

Re: Knowing mouse pressed time?

2009-12-30 Thread slasktrattena...@gmail.com
The performholdAction is your timer's fire method. You set the timer to fire after one second. If the mouse button goes up before that, you invalidate the timer and so performholdAction is never called. -f On Wed, Dec 30, 2009 at 12:42 PM, Gustavo Pizano wrote: > So let me see if I get it. > > S

Re: Knowing mouse pressed time?

2009-12-30 Thread Gustavo Pizano
So let me see if I get it. Start the timer on mouseDown... and invalidate it on mouseUp, got that.. now the performholdAction method that you declared in the example, I call it from within.. ??? because I guess in this method I will check if the time its already 1 sec and show the menu...

Re: Knowing mouse pressed time?

2009-12-30 Thread slasktrattena...@gmail.com
Sorry, haven't had my morning coffee yet. Of course, mouseUp should be: -(void)mouseUp:(NSEvent*)ev { if ( [timer isValid] ) { [timer invalidate]; [timer release]; timer = nil; // perform single-click action } } On Wed, Dec 30, 2009 at 11:53 AM, slasktrattena...@gmail

Re: Knowing mouse pressed time?

2009-12-30 Thread slasktrattena...@gmail.com
Simple. Start a timer on mouse down, invalidate it on mouse up. Something like this (written in mail): NSTimer *timer; -(void)mouseDown:(NSEvent*)ev { timer=[[[NSTimer alloc] blah ...] retain]; } -(void)mouseUp:(NSEvent*)ev { if ( [timer isValid] ) { [timer invalidate]; [tim

Knowing mouse pressed time?

2009-12-30 Thread Gustavo Pizano
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 an