I'm trying to allow the user to select a font of his/her choice using the NSFontManager. I could show the font picker using the following code
@IBAction func fontchangeclicked(_ sender: Any) {
NSFontManager.shared.orderFrontFontPanel(nil)
}
But the NSViewController is unable to recognise this overridden function.
override func changefont(_ sender: Any?) {
guard let fontManager = sender as? NSFontManager else {
return
}
let newFont = fontManager.convert(self.globalfont)
self.globalfont = newFont
}
A list of requirements:
changeFont
instead ofchangefont
.NSObject.changeFont(_:)
is deprecated, useNSFontChanging.changeFont(_:)
instead.NSFontChanging
.changeFont(_:)
is not called when the first responder object handleschangeFont(_:)
.