Re: Getting the final value from an NSSlider drag
Re: Getting the final value from an NSSlider drag
- Subject: Re: Getting the final value from an NSSlider drag
- From: Roland King <email@hidden>
- Date: Tue, 29 Dec 2015 17:45:18 +0800
> On 29 Dec 2015, at 17:40, Quincey Morris <email@hidden> wrote:
>
> On Dec 29, 2015, at 00:44 , Roland King <email@hidden <mailto:email@hidden>> wrote:
>>
>> I want to capture, in the app, the value of the slider only at the end when the mouse goes up, once
>
> Isn’t that what the NSControl property continuous==false is for?
But as I said in the post - the slider is hooked up via bindings in the UI to a label which shows the value *as you slide it*, so it needs to be continuous for that purpose. Then when you let go, only then do I want the final value to be delivered to the app.
were it simply a matter of turning continuous off I wouldn’t have had a problem.
Surprisingly enough the thing I assumed would be the hardest, turned out to be the easiest, mouseDown is documented to start a local event loop capture and it doesn’t return until it’s all over .. so it just took this.
import Cocoa
public protocol RKEndValueSliderTarget : NSObjectProtocol
{
func sliderValueChangeEnded( slider : NSSlider )
}
public class RKEndValueSlider: NSSlider
{
public var endValueReceiver : RKEndValueSliderTarget?
public override func mouseDown( theEvent : NSEvent )
{
super.mouseDown( theEvent )
endValueReceiver?.sliderValueChangeEnded( self )
}
}
_______________________________________________
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