This may be due to the way the table view draws the selected cells ( setSelectionHightLightStyle: . Try setting the style to None / NSTableViewSelectionHighlightStyleNone in your code or in the IB / Storyboard file and draw the selection yourself (in a subclass of NSTableRowView ).
Reference Information. When you use NSTableViewSelectionHighlightStyleRegular or NSTableViewSelectionHighlightStyleSourceList , the table view assumes that you are using standard behavior and selection appearance and some kind of magic supports this.
===========
UPDATE
===========
My previous answer is still valid, but since it describes the problem and suggests a workaround, I would like to add a real solution. If you want to use NSTableViewSelectionHighlightStyleRegular for your type of table (with a custom font and colors), you need a way to "disable" the system magic that will be inserted after the row is selected. One proposed solution is to reject the status of the first responder . It has many shortcomings and is not at all a good solution.
So, let's take a closer look at the system βmagicβ that fires as soon as a line is selected: NSTableRowView has an innerBackgroundStyle property, which, according to the documentation, indicates how the subitems should draw. βIn addition, this value is dynamically calculated based on the set properties set for NSTableRowView. Subclasses can override this value when they draw differently depending on the properties currently displayed. This method can also be called to determine which color should be used. Call a subview, or, alternatively, NSControls may have a -backgroundStyle value in their cell for that value. '
I assume that this style will be passed to the subview hierarchy and make your text fields look weird. The system assumes that the selected cell has a dark background and changes the interiorBackgroundStyle to dark. Other controls are trying to adapt accordingly.
I think there are two problems:
1) Override interiorBackgroundStyle in a subclass of NSTableRowView and return the style that matches your interface (in my case it is .light , because my highlight color is very bright blue). It worked for me.
2) If you change the whole style too much because you want certain elements to not change their style, you may only need to adjust these subclasses. I have not tried it yet.
source share