Reputation: 2970
I have a view-based NSTableView with a dark background color. Cocoa decided that the text in the textfields, popup buttons etc is better readable if the text is white.
This per se is good, I only have the problem that when I edit text in the text fields, the background color while editing is white with white text.
Is there an easy way to get this right (either dark background while editing or dark text while editing) easily or will I need to mess around with the field editor?
UPDATE:
After fiddling around a bit more, I found out that setting the text color on ALL cell view text fields to black changes the text color to black when editing. It however does NOT affect the text color displayed in the table view.
I'm not sure if this is a bug but it looks like one to me.
Upvotes: 1
Views: 442
Reputation: 99
Have you try to override didSelectRowAtIndexPath and didDeselectRowAtIndexPath to update the text color yourself?
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = (UITableViewCell *) [tableView cellForRowAtIndexPath:indexPath];
if([cell isEditing]) {
cell.titleLabel.textColor = [UIColor blackColor];
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = (UITableViewCell *) [tableView cellForRowAtIndexPath:indexPath];
if([cell isEditing]) {
cell.titleLabel.textColor = [UIColor whiteColor];
}
}
This code works on iOS platform but should be easily adapt for OSX platform.
Upvotes: 1