• 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: Setting an NSMenuItem icon with iconForFile leads to slow menus?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting an NSMenuItem icon with iconForFile leads to slow menus?


  • Subject: Re: Setting an NSMenuItem icon with iconForFile leads to slow menus?
  • From: Andrew Platzer <email@hidden>
  • Date: Mon, 6 Jan 2003 16:36:46 -0800

On Monday, January 6, 2003, at 12:16, Daniel Jalkut wrote:
I am using NSWorkspace's iconForFile method to fetch an icon for every file in a large-ish (say, 100 items) hierarchical menu of files in a file system hierarchy. I then set the image on each menu item by first doing a setSize(16,16) on the NSImage and then passing that via setImage to the menu item.

When I first click the menu, there is a long pause, which I've narrowed down to some internal (I think) caching mechanism of the Carbon menu manager as it converts the NSImage for each menu item into a "menu icon" or whatever (I forget the exact terminology from the stack crawl right now.)

I guess my first question is: Is there anyway to get the menu manager to "pre-cache" all the NSImage data it intends to use, so I don't see the hit of that work when the user clicks the menu?

There are some inefficiencies with NSMenu updating which will be addressed in the next release. For now, I would recommend drawing the the icon into a new 16x16 NSImage, creating a NSBitmapImageRep from that, stuff the bitmap into an NSImage and use that as the NSMenuItem image.

Andrew Platzer
Application Frameworks
Apple Computer
_______________________________________________
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: 
 >Setting an NSMenuItem icon with iconForFile leads to slow menus? (From: Daniel Jalkut <email@hidden>)

  • Prev by Date: Re: Unarchiving Individual Windows from a Nib File
  • Next by Date: Re: Quickly drawing non-antialiased, discrete, pixels
  • Previous by thread: Setting an NSMenuItem icon with iconForFile leads to slow menus?
  • Next by thread: Preventing a window from coming to the foreground
  • Index(es):
    • Date
    • Thread