I have an NSDocuments & storyboard app created with the wizard in Xcode 8. In the ViewController Scene I have added a NSTextView. Certain menu items are disabled, such as Bold and Italic.
Looking at the First Responder the actions for bold and italic are not there. Am I supposed to write these methods myself? Is this due to the responder chain not being correctly set up? Why does underline show up but not bold?
Edit: Adding an image to show how I can edit text with the Inspector Bar, but the Format menu does not show the commands I would expect.
There is a historical (?) reason of this problem. When the main menu was created in a xib file, xib file automatically contained a NSFontManager instance and such menu items like Bold were connected to it. However in a modern storyboard, there is no preset NSFontManager instance.
Well then, you can connect them to a FontManager manually following the following steps.
addFontTrait(_:)
action of the fontManager. Likewise, connect "Bigger" and "Smaller" items to modifyFont(_:)
.
You also need to set menuItems' tag, however they are actually already set. Set the correspondent tag also manually only if menuItem's tag is 0
.