• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Knowing mouse pressed time?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Knowing mouse pressed time?


  • Subject: Re: Knowing mouse pressed time?
  • From: Gustavo Pizano <email@hidden>
  • Date: Wed, 30 Dec 2009 12:42:51 +0100

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...

Thanks for the help

G..
PS.. I need a after lunch coffee!!
On Dec 30, 2009, at 12:24 PM, email@hidden wrote:

> 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, email@hidden
> <email@hidden> 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)mouseUp:(NSEvent*)ev
>> {
>>   if ( [timer isValid] ) {
>>       [timer invalidate];
>>       [timer release];
>>       timer = nil;
>>    } else {
>>     // perform single-click action
>>    }
>> }
>>
>> -(void)performHoldAction:(NSTimer*)tmr
>> {
>>   // pop up menu
>> }
>>
>> -fabian
>>
>> On Wed, Dec 30, 2009 at 11:18 AM, Gustavo Pizano
>> <email@hidden> wrote:
>>> 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
>>>
>>

_______________________________________________

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

  • Follow-Ups:
    • Re: Knowing mouse pressed time?
      • From: "email@hidden" <email@hidden>
References: 
 >Knowing mouse pressed time? (From: Gustavo Pizano <email@hidden>)
 >Re: Knowing mouse pressed time? (From: "email@hidden" <email@hidden>)
 >Re: Knowing mouse pressed time? (From: "email@hidden" <email@hidden>)

  • Prev by Date: Re: Notification when displays are detected?
  • Next by Date: Re: Knowing mouse pressed time?
  • Previous by thread: Re: Knowing mouse pressed time?
  • Next by thread: Re: Knowing mouse pressed time?
  • Index(es):
    • Date
    • Thread