PDA

View Full Version : Source List




ranguvar
Oct 19, 2009, 09:24 AM
Hey ho,

I'm trying to create source list like those in the Finder and iTunes. I downloaded Apple's SourceView demo-program and other available source code, but all those programs use NSTreeControllers in their xib-files.
I tried to write my source list without such a controller (this seems somewhat too point-and-clickish), and succeded to some extent.
The problem is that now, the label-font of the expandable items (like the "PLACES", "DEVICES" and "SEARCHES" groups in the Finder) is not grey and inset, and the sub-items' label-font is a little larger than in the Finder (e.g. disk names, "Documents"-folder label, etc.).
How can I fix those issues?

ranguvar


P.S.: Sorry if I'm being unclear, please ask if you don't understand something!



JoshDC
Oct 19, 2009, 01:42 PM
I assume you're using OS 10.5 or later and using NSTableView's support for source lists

[tableView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList]

To get the group appearance, you create a delegate for the table view that impliments:

- (BOOL)tableView:(NSTableView *)tableView isGroupRow:(NSInteger)row

And returns YES if the row is a group row.

To get them the right size, you can change the table view's text cell's size to "small" in interface builder.

ranguvar
Oct 19, 2009, 01:59 PM
I assume you're using OS 10.5 or later and using NSTableView's support for source lists

[tableView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList]

To get the group appearance, you create a delegate for the table view that impliments:

- (BOOL)tableView:(NSTableView *)tableView isGroupRow:(NSInteger)row

And returns YES if the row is a group row.

To get them the right size, you can change the table view's text cell's size to "small" in interface builder.

Thanks so much! Finally I can create source lists!

P.S.: In fact, I use an NSOutlineView, for which the same methods exist.