views:

26

answers:

1

First i need some background color on the text only. Like the headers in the F-Script Browser

alt text

Setting [cell setBackgroundColor: [NSColor blueColor]]; colors the whole cell space not only the text. Also i would need underlined and strikeout text. And to make things readable i would finally like to change the colors (foreground/background) of the selection on the styled items.

Can i do this with the default NSTextFieldCell ?

A: 

Nearly all of these things are jobs for NSAttributedString. As long as the text field cell has rich text enabled, it should accept an attributed string as its object value just fine.

As for the selection color, remember that an NSTextFieldCell is a kind of NSActionCell, and an NSActionCell is a kind of NSCell. NSCells have a method you can override to return a different highlight color. That covers the background; for the foreground, you may have to draw at least the highlighted portion yourself. You may be able to make good use of blend modes in that method.

Peter Hosey
return an attributed string - i should have thought about this. Thanks
Lothar