• 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 to display fonts in the fonts themselves
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPopupButton to display fonts in the fonts themselves


  • Subject: Re: NSPopupButton to display fonts in the fonts themselves
  • From: Graham Cox <email@hidden>
  • Date: Wed, 8 Jul 2009 23:46:53 +1000


On 08/07/2009, at 11:33 PM, I. Savant wrote:

[NSMenuItem setAttributedTitle:];

... and if you want to get really fancy (ie "modern"), you could build the list with regular strings (just "setTitle:") relatively, but use NSOperation/Queue to create / set the attributed titles with the actual fonts in the background, replacing the plain-text ones.


I suggest this because grabbing a list of font name strings is quicker than building an attributed string for each font. Do the quick thing first so it's available, but do the longer fancy thing in the background, updating while the UI is idling. Remember (99.9% of) all AppKit-related stuff should be done on the main thread.


A good idea, though I think the menu delegate can save you even this much effort. The docs are not explicit on this point, but a careful reading suggests that:

- (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)item atIndex: (NSInteger)index shouldCancel:(BOOL)shouldCancel

is actually invoked on some sort of background thread/queue, so implementing these methods (the above + numberOfItemsInMenu:) in your menu delegate would allow you to update each item with the attributed title fairly simply and it wouldn't drag your main thread's performance down.

--Graham


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSPopupButton to display fonts in the fonts themselves
      • From: Peter Ammon <email@hidden>
    • Re: NSPopupButton to display fonts in the fonts themselves
      • From: "I. Savant" <email@hidden>
References: 
 >NSPopupButton to display fonts in the fonts themselves (From: Gideon King <email@hidden>)
 >Re: NSPopupButton to display fonts in the fonts themselves (From: Graham Cox <email@hidden>)
 >Re: NSPopupButton to display fonts in the fonts themselves (From: "I. Savant" <email@hidden>)

  • Prev by Date: Re: NSPopupButton to display fonts in the fonts themselves
  • Next by Date: Re: NSPopupButton to display fonts in the fonts themselves
  • Previous by thread: Re: NSPopupButton to display fonts in the fonts themselves
  • Next by thread: Re: NSPopupButton to display fonts in the fonts themselves
  • Index(es):
    • Date
    • Thread