0
votes

Which NSColor should I use for the text of a selected item in a NSTableView? I have my text field inside a stack view, so the color doesn't get set automatically for selected rows. I tried using NSColor.selectedTextColor, but that's still black in 10.13/light mode. For the moment I'm using NSColor.windowBackgroundColor but that's not going to work in dark mode, where selected rows change the background color but not the text color.

1

1 Answers

0
votes

NSColor.h in the 10.14 SDK shows this as alternateSelectedControlTextColor:

@property (class, strong, readonly) NSColor *alternateSelectedControlTextColor;

/* Foreground color inside emphasized and selected content: table views rows, 
collection views, etc. Equivalent to +labelColor in a NSBackgroundStyleEmphasized 
context.*/

The latter note was also mentioned in the Advanced Dark Mode wwdc talk: https://developer.apple.com/videos/play/wwdc2018/218/?time=2161

Where on 10.14 the main label colors will just automatically switch to have the right look inside that selection.