For cocoa, I have an NSTableView set to be view based. When a row is selected, the text fields change their color to white. How do I keep it black?
I should also note that the Highlight is set to Source List (it does the same thing on Regular).
Unselected row
Selected Row
I was hoping for something similar to the state config for iOS:
This was suggested in WWDC 2011 Session 120 but it's a bit delayed so I'm not going to use it. It may work for someone else though.
- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
[tableView enumerateAvailableRowViewsUsingBlock:^(NSTableRowView *rowView, NSInteger row){
NSTableCellView *cellView = [rowView viewAtColumn:0];
if(rowView.selected){
cellView.textField.font = [NSFont boldSystemFontOfSize:14];
}else{
cellView.textField.font = [NSFont systemFontOfSize:14];
}
}];
}
There is no need for custom code to accomplish that.
Just set the color of the label to "label color" in Interface Builder. The automatic white/black thing only works if the label has the "Control Text Color" set and is in an NSTableCellView.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With