Change Text Color in Table upon selecting

Hi,

So I have a view based Table View with some Text Fields. The text fields have a different color: one is black, one is gray.
When you select this view the black text field will turn to white but the gray one stays gray and becomes almost unreadable. Most Mac OS applications will make all the text fields white and that is what I’m trying to do.

I’ve found the NSBackgroundStyleDark method but I am clueless how to implement this.
Has anyone had any luck with this in AppleScriptObjC? And if so how would one do this?

Thanks in advance.

Jasper

Sadly, I suspect the best answer is to pick another color. I’ve dealt with something similar by changing the way table rows appear when selected, so they just have an outline, but I suspect the code would be far too slow in ASObjC.

Hmm that’s to bad.

I came across this objective-C code though. It’s a delegate of the ItemCellView.
Could this be done in ASOC?


- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle {
	NSColor *textColor = (backgroundStyle == NSBackgroundStyleDark) ? [NSColor windowBackgroundColor] : [NSColor controlShadowColor];
	self.detailTextField.textColor = textColor;
	[super setBackgroundStyle:backgroundStyle];
}

Basically it’s possible if the model of the table view is a custom class.

¢ Create a property textColor with the default (NS)Color in the custom class
¢ Bind that property to the Text Color properties of the text fields in Interface Builder (Table Cell View > objectValue.textColor).
¢ Implement the delegate methods tableView:selectionDidChange and tableView:objectValueForColumn:row in controller class.
¢ When the delegate method is called enumerate selectedRowIndexes and set textColor of the model accordingly.