Hi,

I’m trying to figure out how to correctly calculate the required width of an 
NSScrollView such that it will exactly fit the NSTableView inside, with no 
horizontal scroller and no “filler column” to the right of the last column in 
the table.

The number of columns in the table changes based on the selection in an 
NSPopUpButton elsewhere on the screen. The columns are all the same width and 
are not resizable. When a new selection is made in the popup button, I want to 
reset the table with however many columns correspond to that selection, and 
then resize the scroll view’s width to exactly fit those columns. Both the 
height of the scroll view and the number of rows in the table are fixed, and 
there are more rows than will fit in the scroll view’s height so there will 
always be vertical scrolling — either legacy or overlay style depending on the 
user’s preference — so I need to account for the width of the vertical scroller 
when calculating the required width of the scroll view, if using a legacy 
scroller.

From reading the docs, I gather that [NSScrollView 
frameSizeForContentSize:horizontalScrollerClass:verticalScrollerClass:borderType:controlSize:scrollerStyle]
 can be used to calculate the required frame size for the scroll view — but I 
don’t know how to calculate the required size of the table view to pass as the 
first argument (contentSize). I tried simply summing the column widths and 
using a dummy value for the height (since the height of the scroll view is 
fixed anyway), but that didn’t quite work (as I expected it wouldn’t) — the 
returned size wasn’t wide enough.

Any pointers?

Thanks!
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to