Setting an NSMenuItem icon with iconForFile leads to slow menus?
Setting an NSMenuItem icon with iconForFile leads to slow menus?
- Subject: Setting an NSMenuItem icon with iconForFile leads to slow menus?
- From: Daniel Jalkut <email@hidden>
- Date: Mon, 6 Jan 2003 12:16:27 -0800
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?
Second question would be, based on my impression that the dramatic hit
might be reduced if many of the NSImage objects that were being set
were in fact references to the same object, is there a good way to get
iconForFile to return redundant references to the same NSImage object
instead of a new copy each time? Should I be using iconForFileType
instead?
Thanks for any pointers,
Daniel
_______________________________________________
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.