Skip to content

Instantly share code, notes, and snippets.

@keighl
Created January 12, 2016 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keighl/f2d16abccc753879da7d to your computer and use it in GitHub Desktop.
Save keighl/f2d16abccc753879da7d to your computer and use it in GitHub Desktop.
class Document: NSDocument {
@IBOutlet var fontSizeField: NSTextField?
dynamic var currentFontSize: CGFloat = 0
override func windowControllerDidLoadNib(aController: NSWindowController) {
super.windowControllerDidLoadNib(aController)
fontSizeField.bind("value",
toObject: self,
withKeyPath: "currentFontSize",
options: nil)
}
}
extension Document: NSTextViewDelegate {
func textViewDidChangeTypingAttributes(notification: NSNotification) {
if let font = textView?.typingAttributes[NSFontAttributeName] as? NSFont {
currentFontSize = font.pointSize
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment