On Dec 29, 2015, at 5:44 AM, Graham Cox <graham....@bigpond.com> wrote: > > On 29 Dec 2015, at 7:44 PM, Roland King <r...@rols.org> 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.) Regards, Ken _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com