Sizing NSScrollView width to exactly fit NSTableView
Sizing NSScrollView width to exactly fit NSTableView
- Subject: Sizing NSScrollView width to exactly fit NSTableView
- From: Matthew LeRoy <email@hidden>
- Date: Tue, 07 Jul 2015 15:07:24 +0000
- Thread-topic: Sizing NSScrollView width to exactly fit NSTableView
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 (email@hidden)
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:
This email sent to email@hidden