3

Can anyone let me know what the procedure is to create the grouped NSTableView similar to the Spotlight results.

enter image description here

Jay
  • 6,572
  • 3
  • 37
  • 65
Suhaiyl
  • 1,071
  • 9
  • 17
  • 1
    Are you looking for `NSOutlineView`-like collapse/expand functionality as well or just visual hints to indicate groups? If it's the latter then I suppose the question boils down to how to apply individual row spacings, right? – Jay Oct 29 '12 at 08:19
  • just the visual hint not collapse/expand. – Suhaiyl Oct 29 '12 at 08:51

1 Answers1

4

You probably won't get 100% there with the default behaviour provided by NSTableView, but pretty close.

For OS X v10.5 and up if you provide a NSTableViewDelegate (NSTableViewDelegate Protocol Reference) there's tableView:isGroupRow: you can provide.

Here's what it does for Default and Source List style table views on 10.6:
(setting the grouping flag for folders)

enter image description here

You can also provide tableView:heightOfRow: to adjust the row spacing and it get's pretty close (though with the group and content on different rows):

enter image description here

Other options that come to mind:

  • provide a custom NSCell with image and text plus styling, or
  • (for 10.7 and above) use an NSView based table view and an appropriate template

The TableViewPlayground example might offer a good starting point for the latter.

Jay
  • 6,572
  • 3
  • 37
  • 65