Retired Document
Important: This document has been retired. For information on the font panel, see The Font Panel in Cocoa Text Architecture Guide.
Using the Font Panel
You can enable the interaction between a text object and the font panel using the setUsesFontPanel:
method. Doing so is recommended for a text view that serves as a field editor, for example.
You can use the Font panel on objects other than standard text fields. The NSFontManager method setAction:
sets the action (specified by a selector) that is sent up the responder chain when a new font is selected. The default selector is changeFont:
:. Any object that receives this message from the responder chain should send a convertFont:
: message back to the NSFontManager to convert the font in a manner the user has specified.
This example assumes there is only one font selected:
– (void)changeFont:(id)sender |
{ |
NSFont *oldFont = [self font]; |
NSFont *newFont = [sender convertFont:oldFont]; |
[self setFont:newFont]; |
return; |
} |
If multiple fonts are selected, changeFont:
must send conversion messages for each selected font. This is useful for objects such as table views, which do not inherently respond to messages from the font panel.
Copyright © 1997, 2013 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2013-04-23