Reputation: 25246
I’m seeing some strange behaviour where a NSTextField with an attributed string loses its attributes (for example some text was bold and is no longer bold) when selectable is set and some text is selected.
Setting allowsEditingTextAttributes
to YES
seems to keep the bold attribute, but changes color (white to black).
Is there an easy workaround?
Upvotes: 0
Views: 484
Reputation: 25246
BOOL allowsEditingTextAttributes
Discussion
IfYES
, and the text value is an attributed string, it is displayed using the attributed string’s visual settings, which can be modified in the font panel.; if flag isNO
and the text is an attributed string. the string attributes (font, color, etc.) are ignored and the string is displayed based on the text field’s settings. Setting the attributed string’s attributes are ignored when displaying the string and when the text field is editing.
Text selections in an NSTextField are handled by the field editor. Unfortunately the field editor does not take into account text field’s font and color settings.
For this to work the attribute string needs to include the text field’s font and color settings.
Upvotes: 1