Re: Creating NSOutlineView programmatically
Re: Creating NSOutlineView programmatically
- Subject: Re: Creating NSOutlineView programmatically
- From: Kevin Wojniak <email@hidden>
- Date: Mon, 8 Mar 2010 14:37:02 -0800
You may need to use setOutlineTableColumn: method to set the outline column specifically.
On Mar 8, 2010, at 1:07 PM, Zack Bartel wrote:
> Hi Everyone,
>
> I am trying to create an NSOutlineView programmatically inside of an NSDrawer. I am using the example datasource from /Developer/Examples/AppKit/OutlineView the "FileSystemItem".
> My issue is that although the root item is displayed in the OutlineView, it is not expandable and does not show any of the children. The datasource is identical to the one in the Apple example so I'm guessing my issue is the way I am creating the NSOutlineView in code rather than in IB. The result is that I see an outlineview with one item (the root item) with one table column header and no expand icons. If anyone can see something I'm doing wrong I would very much appreciate the help
> My code is attached.
>
> Thank you ahead of time!
> Zack
>
>
> NSView *contentView = [win contentView];
> [contentView setAutoresizesSubviews:YES];
>
>
> outlineView = [[NSOutlineView alloc] initWithFrame: [contentView frame]];
>
> //DataSource. code is attached below
> ZBFSDataSource *ds = [[ZBFSDataSource alloc] init];
> [outlineView setDataSource: ds];
>
>
> NSTableColumn *c = [[NSTableColumn alloc] initWithIdentifier: @"NAME"];
> [c setEditable: NO];
> [c setMinWidth: 150.0];
> [outlineView addTableColumn: c];
> [c release];
>
> [outlineView reloadData];
>
> scrollView = [[NSScrollView alloc] initWithFrame: [outlineView frame]];
> [scrollView setDocumentView: outlineView];
> [scrollView setAutoresizesSubviews: YES];
>
> NSDrawer *drawer = [[NSDrawer alloc] initWithContentSize:NSMakeSize(200.0, 400.0) preferredEdge:NSMinXEdge];
> [drawer setParentWindow: win];
> [drawer setContentView: scrollView];
> [drawer open];
>
>
> DataSource:
>
> - (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
> return (item == nil) ? 1 : [item numberOfChildren];
> }
>
> - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
> return (item == nil) ? YES : ([item numberOfChildren] != -1);
> }
>
> - (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item {
> return (item == nil) ? [FileSystemItem rootItem] : [(FileSystemItem *)item childAtIndex:index];
> }
>
> - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item {
> return (item == nil) ? @"/" : (id)[item relativePath];
> }
>
>
> _______________________________________________
>
> 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