![]() ![]() The NSFontManager method setAction: sets the action (specified by a selector) that is sent up the first responder chain when a new font is selected. You can use the Font panel on objects other than standard text fields. Doing so is recommended for a text view that serves as a field editor, for example. ![]() You can enable the interaction between a text object and the Font panel using the NSTextView (or NSText) method setUsesFontPanel: method. See Converting Fonts Manually for more information on using the font conversion system. If you want the NSFontManager object to instantiate the Font panel from some class other than NSFontPanel, use the NSFontManager class method setFontPanelFactory. You can also limit the fonts displayed (by default, all fonts are displayed) by assigning a delegate to the application’s font manager object. You can add a custom view object to an NSFontPanel object using setAccessoryView:, allowing you to add custom controls to the Font panel. You can also create (or access) the Font panel using the sharedFontPanel class method. At runtime, the Font panel object is created and hooked into the font conversion system. You do this by dragging a Font or Format menu (which contains a Font submenu) into one of your application’s menus. In general, you add the facilities of the Font panel to your application, along with the NSFontManager object and the Font menu, through which the user opens the Font panel, using Interface Builder. This method must be invoked before the loading of the main nib file. If the delegate returns FALSE, the font isn’t added. ![]() If the delegate returns TRUE (or doesn’t implement this method), the font is added. Before the NSFontPanel object adds a particular font family or face to its list, the NSFontPanel object asks its delegate to confirm the addition by sending the delegate a fontManager:willIncludeFont: message. If this isn’t appropriate for your application-for example, if only fixed-pitch fonts should be used-you can assign a delegate to the NSFontPanel object to filter the available fonts. Normally, an application’s Font panel displays all the standard fonts available on the system. The font manager receives the messages from the Font panel and sends messages up the responder chain for action on the text objects. NSFontManager is the hub for font conversion-that is, changing the traits of a font object, such as its size or typeface. Such changes apply to the selected text or typing attributes for a rich text object or to all the text in a plain text object. It also changes the font in which it displays text in response to messages from the Font panel and Font menu. By default, a text object keeps the Font panel updated with the first font in its selection, or with its typing attributes. Text objects, such as NSTextView, work with NSFontPanel and NSFontManager objects to implement the AppKit’s font conversion system. The Font panel, also called the Fonts window, is a user interface object that displays a list of available font families and styles, letting the user preview them and change the font used to display text. It explains how to use the Font panel in your application, how to work directly with font objects, and how to work with the font manager. This chapter explains how the Cocoa text system deals with fonts.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |