• 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: notification of NSSlider end of tracking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: notification of NSSlider end of tracking


  • Subject: Re: notification of NSSlider end of tracking
  • From: Graham Cox <email@hidden>
  • Date: Sat, 18 Oct 2008 11:44:14 +1100


On 18 Oct 2008, at 6:45 am, Michael Ash wrote:

- (IBAction)sliderMoved:(id)sender {
   SEL trackingEndedSelector = @selector(sliderEnded:);
   [NSObject cancelPreviousPerformRequestsWithTarget:self
selector:trackingEndedSelector object:sender];
   [self performSelector:trackingEndedSelector withObject:sender
afterDelay:0.0];

   // do whatever you want to do during tracking here
}

- (void)sliderEnded:(id)sender {
   // do whatever you want to do when tracking ends here
}

It may not be immediately obvious why this works. Delayed performs
happen in the default runloop mode (unless you specify otherwise using
the variant that has modes: at the end). Event tracking happens in a
special event tracking runloop mode. So the delayed perform won't
happen until the user lets go of the mouse button.

To keep these delayed performs from piling up, this method first
cancels any previous ones before scheduling the new one. An alternate
method would be to have some sort of flag that guarantees you only
schedule one, but this way is simpler and doesn't require a flag.


Reminds me of using a retriggerable monostable in hardware back in the day (that day being before even embedded micros became common) ;-)

--Graham
_______________________________________________

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


References: 
 >notification of NSSlider end of tracking (From: James Walker <email@hidden>)
 >Re: notification of NSSlider end of tracking (From: "Michael Ash" <email@hidden>)

  • Prev by Date: Re: Notification on Login Items change?
  • Next by Date: Re: Objective 2.0 properties
  • Previous by thread: Re: notification of NSSlider end of tracking
  • Next by thread: Delete myDriver.kext files from normal user.
  • Index(es):
    • Date
    • Thread