Question

I'm using an NSScrollView in my Cocoa application, and I want to customize the length of the horizontal scroller. The content of the scroll view is broken up into two main areas: a fixed-width area on the left and a dynamic-width area on the right. The left area only scrolls vertically -- it stays fixed on the left side of the view as the user scrolls left and right. Here's a screenshot of the view being scrolled:

http://jarodlong.com/dropbox/nsscroller_issue.png

I don't want the horizontal scroller to overlap the fixed area on the left. It should be confined to the area on the right.

Is there any way to do this without subclassing NSScrollView? I'd really prefer to not have to subclass, but if it's necessary, what should I look into when doing so?

I've tried just setting the frame of the horizontal scroller, but I think NSScrollView is constantly sizing the scroller to fit the entire area.

Was it helpful?

Solution

I think in this situation I'd use two separate scrollviews, one inside the other.

Ok, I checked with a friend and it turns out that on Lion, you still have NSScroller instances in an NSScrollview, although they're drawn on a GL surface. Not tested, but something like this should do the trick:

@implementation MyScrollView : NSScrollView

- (void) tile
{
[super tile];
id scroller = [self horizontalScroller];
NSRect scrollerRect = [scroller frame];
   // adjust scrollerRect as you want to here
[scroller setFrame:scrollerRect];
}

OTHER TIPS

I'd add two NSScrollViews to your window. The one on the left that only supports vertical scrolling and the one on the right that scrolls horizontally.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top