I've created an iTunes like subclass of NSScroller, however if both the horizontal and vertical scrollers are visible in an NSScrollView or NSTableView I'm left with an ugly white square in the lower right corner. Anyone has a clue on where to add my custom drawing to fill that in with something prettier?
views:
185answers:
1
+2
A:
Ok, I think I have the solution(s).
Either you tell the scrollview not to draw its background, in that case anything below it will fill the corner.
Or, which is what I did, you override the scrollview's drawRect method with the following:
- (void)drawRect:(NSRect)rect{ [super drawRect: rect]; if([self hasVerticalScroller] && [self hasHorizontalScroller]){ NSRect vframe = [[self verticalScroller]frame]; NSRect hframe = [[self horizontalScroller]frame]; NSRect corner; corner.origin.x = NSMaxX(hframe); corner.origin.y = NSMinY(hframe); corner.size.width = NSWidth(vframe); corner.size.height = NSHeight(hframe); // your custom drawing in the corner rect here } }
mekentosj
2010-01-08 09:16:16
A slightly neater solution might be to add support for a subview here, not unlike the cornerView, and overriding the -tile method to position and show/hide that view properly. That way, you can create various neat custom views and just hook them up there, grow boxes, stub fillers, buttons...
uliwitness
2010-01-17 14:44:04