Re: Suggestions for forcing NSSlider to some values, without tickmarks
Re: Suggestions for forcing NSSlider to some values, without tickmarks
- Subject: Re: Suggestions for forcing NSSlider to some values, without tickmarks
- From: Conrad Shultz <email@hidden>
- Date: Thu, 01 Mar 2012 19:14:31 -0800
On 3/1/12 4:13 PM, Graham Cox wrote:
>
> On 02/03/2012, at 11:00 AM, Sean McBride wrote:
>
>> Any suggested subclassing points? That's where I'm stuck really...
>
>
>
> Wait. If you only set one tick mark, it is centred anyway.... does that not do the job for you?
Setting a tick mark has no effect on behavior (e.g. snapping to value)
unless you also tell it to only stop on tick marks, which is not what
Sean wants.
A quick solution I found (tested on 10.7) without subclassing is to set
the slider to update continuously and then implement its selector as, e.g.,
- (void)sliderDidSlide:(id)sender
{
NSNumber *value = [sender objectValue];
double dblValue = [value doubleValue];
if (fabs(dblValue) < 5) {
[sender setObjectValue:[NSNumber numberWithInt:0]];
}
}
This causes a "snap" effect, but (somewhat to my surprise) does allow
you to drag farther and get out of the "snap zone."
--
Conrad Shultz
Synthetiq Solutions
www.synthetiqsolutions.com
_______________________________________________
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