• 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: Getting the final value from an NSSlider drag
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting the final value from an NSSlider drag


  • Subject: Re: Getting the final value from an NSSlider drag
  • From: Uli Kusterer <email@hidden>
  • Date: Wed, 30 Dec 2015 00:55:32 +0100

> On 29 Dec 2015, at 23:45, Ken Thomases <email@hidden> wrote:
>
> On Dec 29, 2015, at 5:44 AM, Graham Cox <email@hidden> wrote:
>>
>> On 29 Dec 2015, at 7:44 PM, Roland King <email@hidden> wrote:
>>>
>>> I can subclass NSSlider or possibly NSSliderCell but that sounds like a whole world of pain, if I have to do that I’ll probably just put a coalescing delay into the whole thing which waits 1/2 second after an update before it actually does the update.
>>>
>>> Any good ways to do this?
>>
>> In your action method, call another method that handles the final value using -performSelector:withObject:afterDelay: but just before you do that, call +[NSObject cancelPreviousPerformRequestsWithTarget:...] for the same message. This schedules a deferred message but immediately cancels it as long as the values come pouring in. On the last time, when you stop moving the slider, the final -performSelector will get to its target and do its work. The afterDelay parameter can be set to whatever value you think you’ll need to allow for a slowly moved slider NOT to fire the final message. I typically use 0.1sec.
>
> This gives false positives if the user simply stops moving the mouse but doesn't release the mouse button.  There's no delay you can specify that avoids this, since there's no upper bound to how long the user can hold the mouse button.  (With assistive technologies, the user doesn't even have to be actually holding anything for the duration.)

 It shouldn't. performSelector:afterDelay: schedules using NSRunLoopDefaultMode, while the slider uses NSEventTrackingRunLoopMode. So it will never fire while the slider is still tracking. In fact, you could use 0.0 as the delay.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://stacksmith.org





_______________________________________________

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: 
 >Getting the final value from an NSSlider drag (From: Roland King <email@hidden>)
 >Re: Getting the final value from an NSSlider drag (From: Graham Cox <email@hidden>)
 >Re: Getting the final value from an NSSlider drag (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Getting the final value from an NSSlider drag
  • Next by Date: Re: Getting the final value from an NSSlider drag
  • Previous by thread: Re: Getting the final value from an NSSlider drag
  • Next by thread: Re: Getting the final value from an NSSlider drag
  • Index(es):
    • Date
    • Thread