Which Cocoa control to use to display drill-down table? - macos

Any idea which Cocoa control to use to display the drill-down table as in attached screenshot? On the left panel is a list of items. When an item is selected, the detail of the item is displayed on the right panel. Is it NSOutlineView or NSBrowser? Thanks!
Screenshot http://s1.proxy03.twitpic.com/photos/large/409079140.png
Link to twitpic page

It's an NSTableView on the left, and most likely an NSTextView on the right. The NSTableView on the left most likely has an NSDateFormatter set for the cell in the third column, which handles converting an NSDate object into the NSString value that's shown.
See Table View Programming Guide for more general info on NSTableViews. There is also NSOutlineView, which is a subclass of NSTableView, for when you need to display a data tree. Implementing a table view is much easier than an outline view or NSBrowser, so only go with an outline view if you really need to.

NSOutlineView will produce something like the left panel, but is probably overkill judging by your screenshot.
NSBrowser would give you a Finder-style drill down.
I would personally use two views - an NSTableView on the left and an NSTextView on the right.

Related

View and Cell based NSTableView

What is the main difference between cell based and view based tableviews in Cocoa.
The understanding I have is cell based tableviews are basically used for displaying strings and view based are for custom cells.User events such as dragging rows, selection etc can be handled in view based.
cell based tableviews use objectValueForTableColumn: method and view based tables use viewForTableColumn: method.
Is my understanding correct?. Or is any other design concerns between these table views. When to go for cell based and when to go for view based.
Thanks in advance
short answer:
A cell can contain only one UI element like a text cell, image view cell, button cell and a few more. The customization ability is quite poor.
A view can contain multiple UI elements as well as other views. The customization ability is almost infinite.
Apple recommends to use always view based table views
NSCell is a lighter weight object and was a solution when it was a concern to have too many NSView objects.
Think more than a decade ago.
Cells are deprecated.
Use views.

How to create a treeview like structure in Nstableview for OSX?

How do I show two records in columns for a nstableview. When clicking on each row I want to expand the nstableview and show some more records under that selected row like a tree view.
Your question is so broad I can only give a broad answer: in Cocoa, what you call a "tree view" is known as an outline view. You can use NSOutlineView to implement it. See the Outline View Programming Topics.

NSSplitView Holding Priorities not shown in IB, why?

I am puzzled and could swear I set my NSSplitView holding priorities in IB some days ago, but now they don't seem to be visible in IB at all. Does anyone else see holding priorities in the top left of Xcode's IB when the splitView is selected ?
Does your split view have subviews? I can reproduce what you're seeing if I delete all subviews from a split view. That section shows one slider for each subview.
Update:
You are using the new NSSplitViewController and NSSplitViewItem classes introduced with Yosemite. Because of that, your split view does not, in fact, have subviews in the NIB. (There's no triangle toggle to disclose subviews under the split view.) The split view items will provide views on demand via their view controllers.
The holding priority is a property of the split view item. I can't verify at the moment, but I expect that Xcode will provide a means to set it if you select the individual items.

Validating a drag to an NSCollectionView isn't reflected visually

I have an NSCollectionView that I want to accept items dragged from elsewhere in my application.
I implement collectionView:validateDrop:proposedIndex:dropOperation: and collectionView:acceptDrop:index:dropOperation: in the collectionview's delegate and register for the appropriate dragged types. Both methods get called fine when I drag the appropriate types, but I don't get a blue focus ring over the collectionview indicating a valid drag.
Have tried both the collection view and its containing scroll view on Default and External settings for the focus ring. Both are just the standard non-derived Cocoa classes. Wondered if there was anything else I should try. Surely it isn't necessary to subclass NSCollectionView for this?
Thanks
Chris
Focus rings are not typically the correct way to provide feedback about drag destinations. Every view does it slightly differently. NSTextView shows the insertion bar. NSTableView shows a blue line in between rows for Before drop operations, and shows a bezel around the row for On drop operations. (See NSTableViewDropOperation)
NSCollectionView shows a "gap" between existing subviews to show where the items will be dropped for Before drop operations, and it will set the selected property on NSCollectionViewItem to YES for On drop operations. (Note: NSCollectionViewItem doesn't do anything by default to visibly represent the selected property. You must implement that yourself.)
Since NSCollectionView's feedback uses existing subviews only, it appears there isn't any feedback at all for empty NSCollectionView's. You would need to subclass to provide this behavior yourself. You could also file a bug to request that NSCollectionView do this itself.

Cocoa: How to make table view draw custom views in each cell

I am learning Cocoa and trying to create an application for Mac that displays a simple book list. Each book is an NSView with its cover image, title and author. I want to present this list as a NSTableView with a single column and a book view in each cell. However i can't yet figure out how to display a custom view inside a table cell in interface builder or programmatically. Any tips would be very appreciated :)
Inso.
If all of your "book views" are the same size, why not use NSCollectionView / NSCollectionViewItem? It's a much cleaner solution (provided they're all sized the same).
Assuming a collection view wouldn't be a better solution, what you need to do is to write a custom cell. The column owns exactly one such cell, which the table view will use to draw the column's value for each row.
(If you came from the iPhone, yes, this is completely different from UITableView. Each NSTableColumn has exactly one cell, which it uses for every row.)
If you're using your NSView class somewhere else, then you could make it into a subclass of NSControl and have it use another instance of the same cell class. Like most controls, all the real work would be done by the cell, which enables you to reuse that behavior in multiple controls (your single control and your table view).
See Control and Cell Programming Topics for more info.
Apple added view-based table views in Lion, so you should be able do this natively with NSTableView, now.
(You still can't put an NSView in an NSCell—that wouldn't make sense. But you can have views instead of cells in a table view.)

Resources