• 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: Andreas Mayer <email@hidden>
  • Date: Thu, 31 Dec 2009 14:25:48 +0100


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 -performSelector:withObject:afterDelay: (which obviously uses a timer of some sort)


- (void)mouseDown:(NSEvent *)theEvent
{
// send openMenu: to self after 0.8 seconds
[self performSelector:@selector(openMenu:) withObject:nil afterDelay: 0.8];
}


- (void)mouseUp:(NSEvent *)theEvent
{
// user released mouse button - cancel previous perform request
[NSObject cancelPreviousPerformRequestWithTarget:self selector:@selector(openMenu:) object:nil];
}


(Typed in Mail.app)


Andreas _______________________________________________

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: Gustavo Pizano <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: "Henry McGilton (Boulevardier)" <email@hidden>)
 >Re: Knowing mouse pressed time? (From: Gustavo Pizano <email@hidden>)
 >Re: Knowing mouse pressed time? (From: "Henry McGilton (Boulevardier)" <email@hidden>)
 >Re: Knowing mouse pressed time? (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Knowing mouse pressed time?
  • 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