• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSPopupButton and fonts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >NSPopupButton and fonts (From: Jacques Foucry <email@hidden>)

  • Prev by Date: Re: number formatting
  • Next by Date: Re: Please help?...
  • Previous by thread: NSPopupButton and fonts
  • Next by thread: Changing the default color in an NSTextView?
  • Index(es):
    • Date
    • Thread