Re: Source Lists
Re: Source Lists
- Subject: Re: Source Lists
- From: Jim Puls <email@hidden>
- Date: Fri, 26 Oct 2007 17:04:35 -0700
On Oct 26, 2007, at 2:31 PM, Thomas Davie wrote:
Hi list,
Leopard has the ability to specify that an outline view is a source
list, but what I haven't figured out, is how to replicate the
headings (e.g. "DEVICES" in Finder). I could of course return an
NSAttributedString to the outline view, but I get the feeling that's
the wrong way to do it (TM). I then have to guess what styles the
text should have, and as soon as apple update, it will look odd.
Can anyone recommend to me what the right way to do this is?
I guess they've officially given the go-ahead, so here's a Leopard-
only solution to make things look right. Getting the selection and
drag behavior right is left as an exercise for the reader.
Implement the following delegate methods for NSOutlineView with the
source list style turned on. Assuming, of course, that you're using a
subclass of NSTextFieldCell for display. Return a regular NSString as
the object value for the table column.
- (BOOL)outlineView:(NSOutlineView *)sender isGroupItem:(id)item {
if (ITEM IS HEADING)
return YES;
else
return NO;
}
- (void)outlineView:(NSOutlineView *)sender willDisplayCell:(id)cell
forTableColumn:(NSTableColumn *)tableColumn item:(id)item {
if (ITEM IS HEADING) {
NSMutableAttributedString *newTitle = [[cell
attributedStringValue] mutableCopy];
[newTitle replaceCharactersInRange:NSMakeRange(0,[newTitle
length]) withString:[[newTitle string] uppercaseString]];
[cell setAttributedStringValue:newTitle];
[newTitle release];
}
}
-> jp
_______________________________________________
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
References: | |
| >Source Lists (From: Thomas Davie <email@hidden>) |