Re: NSTableView fixed columns
Re: NSTableView fixed columns
- Subject: Re: NSTableView fixed columns
- From: Dave Rosborough <email@hidden>
- Date: Thu, 19 Feb 2004 14:48:07 -0800
Geez, I love Cocoa. Talk about simplicity. The problem is getting two
tableViews to scroll side-by-side with a single vertical scroll bar.
In summary, for us Objective-C types, I just subclassed the
NSScrollView of which my NSTableView was a subview.
In this subclass, add an IBOutlet for your other tableView (note: not
the NSScrollView it is in, but the NSTableView itself), then simply
override the "reflectScrolledClipView:" method as shown (just a
translation of Moray's solution in Java):
- (void)reflectScrolledClipView:(NSClipView *)aClipView
{
[super reflectScrolledClipView:(NSClipView *)aClipView];
[otherTableView scrollRectToVisible:[aClipView documentVisibleRect]];
}
Voila, the two table views now scroll side by side. Wow. And I
thought it was going to be tough! Thanks to Moray who provided the
Java solution.
TTYL
DaveR
On 19-Feb-04, at 11:13 AM, Moray Taylor wrote:
>
Hi Dave,
>
>
I had this exact same problem a couple of days ago, I have done it
>
using two NSTableViews and syncing them, with code like this (Java,
>
but I'm sure the principle is the same in Obj-C.)
>
>
public void reflectScrolledClipView(NSClipView aClipView) {
>
super.reflectScrolledClipView(aClipView);
>
>
GridRowCounter.scrollRectToVisible(aClipView.documentVisibleRect());//
>
sync the other view
>
}
>
}
>
>
This code is in my subclass of the 'master' NSScrollview that
>
encompasses my primary NSTableView.
>
>
GridRowCounter is another NSTableView, which also has an NSScrollView
>
(with all the furniture turned off.)
>
>
When I scroll the 'master' NSScrollView, the other one scrolls with it.
>
>
Let me know if you need to know anything else.
>
>
Cheers
>
>
Moray
>
>
>
> Hello all!
>
>
>
> I currently have a subclass of an NSTableView in which I'm displaying
>
> a whole bunch of columns. Basically, what I'd like to do is keep two
>
> or three columns fixed in place on the left side of my view, and be
>
> able to scroll through the rest of the columns horizontally - the
>
> columns on the left need to be visible all the time.
>
>
>
> What is the best way to go about implementing this? Is there a
>
> convenient way to subclass NSTableView to do this, or do I create two
>
> separate tableviews side by side and make them subviews in a
>
> scrollview?
>
>
>
> If anyone has any suggestions on how to get started, I'm sure I can
>
> figure it out... just having a hard time deciding what is the best
>
> approach to start hacking away at.
>
>
>
> Thanks!
>
> DaveR
>
> _______________________________________________
>
> cocoa-dev mailing list | email@hidden
>
> Help/Unsubscribe/Archives:
>
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
> Do not post admin requests to the list. They will be ignored.
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.