开发者

How to resize NSOutlineView column when scroller appears/disappears?

开发者 https://www.devze.com 2022-12-21 23:43 出处:网络
This ought to be very basic but after trying for an hour or so I can\'t figure out how to do this correctly:

This ought to be very basic but after trying for an hour or so I can't figure out how to do this correctly:

I have a NSOutline view with two columns, of which the right one should always be fully visible. The enclosing NSScrollView is set to show a vertical scroller only. Now whenever the vertical scroller appears it covers part of the right column. What I would like to achieve however, is that the right column 开发者_如何学Gomoves left so that it's still fully visible.

I've first tried fiddling with the resizing options in IB for a while but this didn't seem to do the trick.

I've then created a custom NSOutlineView with

-(void)viewWillDraw {
 CGRect contentFrame = [[[self enclosingScrollView] contentView] frame];
 CGRect ourFrame = self.frame;

 CGFloat correction = ourFrame.size.width - contentFrame.size.width;

 //resize the first column when the scrollbar appears 
 [[self outlineTableColumn] setWidth:kOutlineColumnWidth - correction];

 [super viewWillDraw];
}

Problem is, the function gets called several times when the scroller disappears and the column grows and shrinks a few times for some reason which is pretty ugly. Also when the window loses focus, the left column grows back to normal size causing the right column to be covered by the scroller again.

0

精彩评论

暂无评论...
验证码 换一张
取 消