Context:
In Interface Builder I have a non-editable label (NSTextField
). The contents of the label is created using Cocoa Bindings. The value of the binding is an NSAttributedString
(created using a talue transformer). See image:
The value transformer essentially specifies the font for specific characters, as per Markdown formatting (i.e. Italic and Bold). Such that String
--> NSAttributedString
. The label's attributedStringValue
is changed appropriately
Issue:
When selecting the label in the UI. The font resets to what is specified in IB, and not what was set as the NSAttributedString
. If you don't select the text then everything looks good.
Before clicking on the label:
After clicking/selected the label:
Attempted Solutions:
- I've tried subclassing
NSTextField
but there's nothing really to override that enables me to disable any font changes when the text is selected. - I've tried disabling rich text. This actually helps a lot by not changing the normal text, but it still strips the formatting from the bold and italic text
- Most similar issues out there are with
NSTextView
s notNSTextField
s