Re: NSTableView within NSScrollView in code
Re: NSTableView within NSScrollView in code
- Subject: Re: NSTableView within NSScrollView in code
- From: Patrick Mau <email@hidden>
- Date: Thu, 11 Nov 2010 13:29:07 +0100
Hallo Jerry
Thanks a lot. You got me going ...
Here's what I did:
defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:self
selector:@selector(clipviewFrameChanged:)
name:NSViewFrameDidChangeNotification
object:[scrollView contentView]];
- (void)clipviewFrameChanged:(NSNotification *)aNotification
{
[tableView sizeToFit];
}
After all the setup, I add an observer to the NSClipView
that is the scrollvies's contentView.
Whenever the clipview changes, I poke the tableview
as you suggested.
Thanks a lot for the idea !!!
Two sidenotes if someone cares:
1)
The corresponding setup in IB (TableView in ScrollView, which tracks window size),
creates a scrollview that has both the documentView and the contentView pointing to the
identical NSClipView (checked with gdb). This setup can not be done in code, setting
the documentView changes something in the clipView leading to an exception
2)
I have created a custom TableColumn, implementing "setWidth:" by just calling
super. If you do so, you can look at the backtrace.
You'll note that the clipView post a frame change notification, which will
be observed in 'superviewFrameChanged:' in te tableview.
The fits thing I tried was to implenent that:
[defaultCenter addObserver:tableView
selector:@selector(superviewFrameChanged:)
name:NSViewFrameDidChangeNotification
object:[scrollView contentView]];
Strange thing, it does NOT work, allthough the contentView
is in fact posting these notifications.
I checked this by simply implementing the first snippet.
Cheers and thanks for reading.
Patrick
On 11.11.2010, at 05:11, Jerry Krinock wrote:
>
> On 2010 Nov 10, at 14:09, Patrick Mau wrote:
>
>> So someone must tell the tableView that it should resize its colums in response
>> to a scrollview frame change.
>
> Try poking it with -[NSTableView sizeLastColumnToFit] or -[NSTableView sizeToFit].
>
> _______________________________________________
>
> 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
_______________________________________________
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