Reputation: 6862
The NSScroller
automatically expands it's width when the user hovers over it.
However, the document view has pretty little space, and this is why the scroller should not expand.
How can I disable this behaviour?
Upvotes: 0
Views: 390
Reputation: 2052
This maybe a little too late, but something like this might help?
1) Create custom scroller for your vertical scrollbar.
2) Override -drawKnob to force draw knob the default size even when it is to be drawn 'expanded'.
-(void)drawKnob
{
NSRect knobSlot = [self rectForPart:NSScrollerKnob];
if(sFlags.isHoriz)
{
knobSlot.size.height = 9;
knobSlot.origin.y = 6;
}
else
{
knobSlot.size.width = 9;
knobSlot.origin.x = 6;
}
NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:knobSlot xRadius:5 yRadius:5];
[[NSColor scrollBarColor] set];
[path fill];
}
3) Depending on if you still want the knob slot or not, override -drawKnobSlotInRect:
-(void)drawKnobSlotInRect:(NSRect)slotRect highlight:(BOOL)flag
{
NSRect newRect = slotRect;
if(sFlags.isHoriz)
newRect.origin.y = 4;
else
newRect.origin.x = 4;
[super drawKnobSlotInRect:newRect highlight:flag];
}
Upvotes: 1