I played a little and at least started out pretty well with a subclass of NSSliderCell .
MDSliderCell.h :
MDSliderCell.m :
#import "MDSliderCell.h" @implementation MDSliderCell - (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView { if ([self numberOfTickMarks] > 0) tracking = YES; return [super startTrackingAt:startPoint inView:controlView]; } #define MD_SNAPPING 10.0 - (BOOL)continueTracking:(NSPoint)lastPoint at:(NSPoint)currentPoint inView:(NSView *)controlView { if (tracking) { NSUInteger count = [self numberOfTickMarks]; for (NSUInteger i = 0; i < count; i++) { NSRect tickMarkRect = [self rectOfTickMarkAtIndex:i]; if (ABS(tickMarkRect.origin.x - currentPoint.x) <= MD_SNAPPING) { [self setAllowsTickMarkValuesOnly:YES]; } else if (ABS(tickMarkRect.origin.x - currentPoint.x) >= MD_SNAPPING && ABS(tickMarkRect.origin.x - currentPoint.x) <= MD_SNAPPING *2) { [self setAllowsTickMarkValuesOnly:NO]; } } } return [super continueTracking:lastPoint at:currentPoint inView:controlView]; } - (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag { [super stopTracking:lastPoint at:stopPoint inView:controlView mouseIsUp:flag]; } @end
Basically, during -continueTracking:at:inView: it checks how close it is to the check mark, and if it's close enough, it includes an option that allows you to only check the check mark. This makes it snap to the check mark, and then when you go far enough, you enable the βcheck onlyβ option until you get close to the other mark.
NSGod source share