Search code examples
cocoansoutlineviewnsprogressindicatorpxsourcelist

Adding NSProgressIndicators to an NSOutlineView subclass


I'm using a heavily modified version of the fantastic PXSourceList control to emulate other popular OS X source lists. Unfortunately I've run into some issues while attempting to add NSProgressIndicator's to rows within said source list.

PXSourceList acts as a subclass of the standard NSOutlineView control and comes packaged with an example SourceListItem class (a skeletal NSObject subclass). Rendering of the PXSourceList and its SourceListItem's is handled in PXSourceList's drawRow:clipRect: method, which is the source of my problem.

I'm trying to find the best way of allowing each SourceListItem to optionally display an NSProgressIndicator. Instinct tells me I should be creating a custom cell, but I'm unsure as to how I should optimally implement a decent solution.

Any and all help would be appreciated.


Solution

  • There is a great example in the Apple Sample code that does this (alas not using PXSourceList).

    Animated TableView Sample

    Also look at this answer for commentary and links to some sample code: How to display indeterminate NSProgressIndicator in the NSOutlineView?

    In essence, as their is no NSProgressIndicatorCell class, you need to create a subview containing an NSProgressIndicatorView and display it at the appropriate row in your tableview.