I am creating a custom NSSlider with a custom NSSliderCell. Everything works beautifully, except for a pen. When I drag it to the maximum value, the handle is cropped, I can only see 50% of the image of the handle.
When assigning my custom NSSliderCell, I set the knobThickness to the width of the image, which I use as a slider. I assumed (I think mistakenly) that this takes this into account and stops it from clipping?
Any ideas what I'm doing wrong? The slider gets into maxValue only when the handle is cut off by 50%, so it does not move without adding any value.
- (void)drawKnob:(NSRect)knobRect { NSImage * knob = _knobOff; knobRectVar = knobRect; [[self controlView] lockFocus]; [knob compositeToPoint: NSMakePoint(knobRect.origin.x+4,knobRect.origin.y+knobRect.size.height+20) operation:NSCompositeSourceOver]; [[self controlView] unlockFocus]; } - (void)drawBarInside:(NSRect)rect flipped:(BOOL)flipped { rect.size.height = 8; [[self controlView] lockFocus]; NSImage *leftCurve = [NSImage imageNamed:@"customSliderLeft"]; [leftCurve drawInRect:NSMakeRect(5, 25, 8, 8) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1]; NSRect leftRect = rect; leftRect.origin.x=13; leftRect.origin.y=25; leftRect.size.width = knobRectVar.origin.x + (knobRectVar.size.width/2); [leftBarImage setSize:leftRect.size]; [leftBarImage drawInRect:leftRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction:1]; [[self controlView] unlockFocus]; }
source share