Font menu in an NSPopUpButton

  • I want an NSPopUpButton that contains a list of fonts. I see that
    Interface Builder supplies a menu for fonts that you can put into
    your menubar menus, but I don't see a way to create a popup button
    with fonts in it. What's the recommended way to do that?

    Thanks,
    Darrin
    --
    Darrin Cardani - <dcardani...>
    President, Buena Software, Inc.
    <http://www.buena.com/>
    Video, Image and Audio Processing Development
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • On Thursday, October 16, 2003, at 04:41  PM, Darrin Cardani wrote:
    > I want an NSPopUpButton that contains a list of fonts. I see that
    > Interface Builder supplies a menu for fonts that you can put into your
    > menubar menus, but I don't see a way to create a popup button with
    > fonts in it. What's the recommended way to do that?

    You should be able to set the menu of your popup button to use the
    result of -[NSFontManager fontMenu:].

      -- Chris

    --
    Chris Hanson, bDistributed.com, Inc.  |  Email: <cmh...>
    Custom Mac OS X Development          |  Phone: +1-847-372-3955
    http://bdistributed.com/              |  Fax:  +1-847-589-3738
    http://bdistributed.com/Articles/    |  Personal Email: <cmh...>
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • On Thursday, October 16, 2003, at 02:41  PM, Darrin Cardani wrote:

    > I want an NSPopUpButton that contains a list of fonts. I see that
    > Interface Builder supplies a menu for fonts that you can put into your
    > menubar menus, but I don't see a way to create a popup button with
    > fonts in it. What's the recommended way to do that?

    Programmatically. Here's how I do it in one of my apps:

    // Populate font pop-up.
    fontList = [[NSMutableArray alloc] initWithArray:[[NSFontManager
    sharedFontManager] availableFontFamilies]];
    [fontList sortUsingSelector:@selector(caseInsensitiveCompare:)];
    [fontListPopup removeAllItems];
    [fontListPopup addItemsWithTitles: fontList];
    [fontList release];

    It's simple enough.
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • I had asked:

    I want an NSPopUpButton that contains a list of fonts. What's the
    recommended way to do that?

    At 6:41 PM -0500 10/16/03, Chris Hanson wrote:
    > You should be able to set the menu of your popup button to use the
    > result of -[NSFontManager fontMenu:].

    I should have been more clear. The above will give you the font menu
    which has commands in it, such as the one to bring up the font
    palette, and commands for changing kerning, ligatures, letters, etc.
    What I wanted was a list of font families. Dustin's suggestion gives
    that:

    At 4:54 PM -0700 10/16/03, Dustin Voss wrote:
    > Programmatically. Here's how I do it in one of my apps:
    >
    > // Populate font pop-up.
    > fontList = [[NSMutableArray alloc]
    > initWithArray:[[NSFontManager sharedFontManager]
    > availableFontFamilies]];
    > [fontList sortUsingSelector:@selector(caseInsensitiveCompare:)];
    > [fontListPopup removeAllItems];
    > [fontListPopup addItemsWithTitles: fontList];
    > [fontList release];

    Thanks!
    Darrin
    --
    Darrin Cardani - <dcardani...>
    President, Buena Software, Inc.
    <http://www.buena.com/>
    Video, Image and Audio Processing Development
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
previous month october 2003 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Go to today