IluTov
IluTov

Reputation: 6862

Not expanding NSScroller

The NSScroller automatically expands it's width when the user hovers over it.

enter image description here

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

Answers (1)

lead_the_zeppelin
lead_the_zeppelin

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

Related Questions