NSCell Subclassing: Draw NSProgressIndicator?

361 Views Asked by At

I am using a cell-based NSTableView. Is there any way to create a custom NSCell subclass and draw a NSProgressIndicator in it?

Something similar to:

-(void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView{
  [myProgressControl drawOnView:controlView]; //?
}

The NSProgressIndicator itself works as status indication only and does not interact with the user (no mouse clicks etc needed).

I'd like to stick to a cell-based NSTableView since I use NSTableViewDataSource. NSLevelIndicatorCell is an alternative however I prefer the look/design of the NSProgressIndicator

1

There are 1 best solutions below

2
Ken Thomases On

First, I'm not sure what you mean by "I'd like to stick to a cell-based NSTableView since I use NSTableViewDataSource". There's no incompatibility between view-based table views and NSTableViewDataSource, although some things work a little differently.

Anyway, Apple has a sample project, AnimatedTableView, that shows using progress indicators in an NSCell-based table view. It's not done by using a custom cell class. Rather, the progress indicator is added to the table view as a subview. It's effectively a poor-man's version of a view-based table view from before there was such a thing.

Needless to say, I recommend that you switch to a view-based table view, rather than using that convoluted approach.