DrummerB
DrummerB

Reputation: 40211

NSAttributedString in view-based NSOutlineView rendering as normal string?

I'm trying to add some formatting to the cells in a view-based NSOutlineView. No matter what I try, the text is rendered without any format I specify. This is my current approach:

NSMutableAttributedString *versionString = [[NSMutableAttributedString alloc] 
                                             initWithString:myString];
[versionString addAttribute:NSForegroundColorAttributeName 
                      value:[NSColor redColor] range:NSMakeRange(0, 3)];

NSTableCellView result = [outlineView makeViewWithIdentifier:@"DataCell" 
                                                       owner:self];
result.textField.allowsEditingTextAttributes = YES;
result.textField.attributedStringValue = versionString;

Is it not possible to render attributed strings in a NSOutlineView and a standard NSTextField?

Upvotes: 2

Views: 623

Answers (1)

DrummerB
DrummerB

Reputation: 40211

Okay, the problem was that the outline view highlight style was Source. Setting that to Regular or None will allow attributed strings.

Upvotes: 8

Related Questions