Make NSButton open fonts panel

2019-02-22 05:30发布

问题:

I was wondering how to go about making a button open up the fonts panel in Mac OS X using Cocoa, I have an NSTextView in my application and want the fonts dialogue to display when the user clicks the button. Thanks in advance!

回答1:

The last object that comes by default (those one that you see in the left from the editing area) is exactly the Font Manager. All you have to do is to control drag from your button to the font manager and connect the orderFrontFontPanel: action.