NSTextField font recycling is reset when selected

Context:

In Interface Builder, I have an editable label ( NSTextField). Label content is created using Cocoa Bindings. The binding value is this NSAttributedString(created using a talue transformer). See Image:

Binding

A value converter essentially defines a font for certain characters according to Markdown formatting (i.e., italics and bold). Such that StringNSAttributedString. Label attributedStringValuechanges accordingly

Question:

When selecting a label in the user interface. The font is reset to what is indicated in IB, and not what was set as NSAttributedString. If you do not select text, then everything looks good.

Before clicking on the label:

enter image description here

/ :

enter image description here

:

  • NSTextField, , .
  • . , , - .
  • NSTextView not NSTextField s
+1
1

allowEditingTextAttributes = true

:

class ViewController: NSViewController {

dynamic var markdownText : String?

@IBOutlet weak var label: NSTextField!

override func viewDidLoad() {

    super.viewDidLoad()

    label.allowsEditingTextAttributes = true
}
}

, :

enter image description here

: https://github.com/emankovski/BindingFormattedText

+2

All Articles