• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Source Lists
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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>)

  • Prev by Date: Suggested forum for technical Leopard discussion that isn't specifically Cocoa related?
  • Next by Date: Re: Suggested forum for technical Leopard discussion that isn't specifically Cocoa related?
  • Previous by thread: Re: Source Lists
  • Next by thread: Re: Source Lists
  • Index(es):
    • Date
    • Thread