Re: NSPopupButton and fonts
Re: NSPopupButton and fonts
- Subject: Re: NSPopupButton and fonts
- From: Jim Correia <email@hidden>
- Date: Sat, 23 Feb 2002 12:27:22 -0500
On Saturday, February 23, 2002, at 11:12 AM, Jacques Foucry wrote:
How can I build a menu using NSPopupButton with names of the fonts
installed on the system ? Like in the preferences of Mail.app ?
If you do not want to use the font picker, and instead use a popup menu
you should be able to get the names of the available fonts from the font
manager and build the popup.
- (void)awakeFromNib
{
NSMutableArray *fonts;
NSEnumerator *enumerator;
NSString *font;
[popup removeAllItems];
fonts = [[[NSFontManager sharedFontManager] availableFontFamilies]
mutableCopy];
[fonts sortUsingSelector: @selector(compare:)];
enumerator = [fonts objectEnumerator];
while (nil != (font = [enumerator nextObject]))
{
[popup addItemWithTitle: font];
}
[fonts release];
}
You'll may also want to put tags on the items or set the represented
object so you can later determine things about the font that was chosen.
Jim
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.