1

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

  • It seems like its a lot of work but if you switch to view-based NSTableView, you gain a lot more control over it. You will have to implement NSTableViewDataSource better but it's worth it. That way you will create much better cells. If you stay with the cell-view you are going to be limited to a few options. – Farini Oct 11 '15 at 17:38

1 Answers1

1

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.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • Using cell-based NSTVs I only need to set column identifiers, which simplifies things a lot. Using a view-based NSTV I need to return a NSView for each column. Also a DataSource would be kind of useless when you request data from it in an array-like manner. (DataSource.Items[index]) –  May 11 '15 at 18:46
  • 1
    If the cell view in the NIB has the same identifier as the table column (and Xcode assigns both to match automatically, by default), then you don't need to implement the delegate method to return the view. It is found automatically. So, no disadvantage there compared to `NSCell`-based table views. I have no idea what you mean about the data source being useless. The view-based table view uses it just the same as an `NSCell`-based one. The only area of difference *can be* in how the cell view handles the `objectValue` it's handed, but it can be made to work very similarly. – Ken Thomases May 11 '15 at 19:03