Devarshi
Devarshi

Reputation: 16758

Showing text in selected row in NSTableView as white

In my application I have taken a table view and displaying some NSString objects within it. User can also edit any row within it.

When I do not change color of NSTextFieldCell in NSTableColumn in IB, it shows default display property of table view ie. when a row is selected, text of selected row starts appearing white, but when I change it to some other color, say blue, then it starts appearing like this:

alt text

To resolve this problem I tried to set text color of cell in selected row as white in table delegate method: tableView:willDisplayCell:forTableColumn:row:, but it caused another problem- text remained white when edited, thus it became difficult for user to identify text entered:

alt text

Can anyone suggest me some suitable solution to resolve it?

Thanks,

Miraaj

Upvotes: 1

Views: 1605

Answers (1)

Peter Hosey
Peter Hosey

Reputation: 96353

Test whether the cell is highlighted. If it is, set its text color to [NSColor alternateSelectedControlTextColor]. If not, set it to blue (or [NSColor controlTextColor] for the regular text color).

Upvotes: 2

Related Questions