views:

221

answers:

1

I've got an column of cells in an NSTableView that get their text color from the app's preference plist. I want to set the text color to white when highlighted, but have been unable to figure out a good way to do this.

Anybody got any ideas?

+2  A: 

Assuming there's no easier way to do this, implement the tableView:willDisplayCell:forTableColumn:row: delegate method to set the cell's textColor to either [NSColor alternateSelectedControlTextColor] or [NSColor selectedControlTextColor] depending on whether rowIndex is in the table view's selectedRowIndexes set.

(The “selected” in “{alternateS,s}electedControlTextColor” refers to the control, not the text. You're using the alternate (or not alternate) text color for the selected control, which is the table view.)

Peter Hosey