• 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: Turning NSMenuItem into separator
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Turning NSMenuItem into separator


  • Subject: Re: Turning NSMenuItem into separator
  • From: Andy Lee <email@hidden>
  • Date: Fri, 30 Sep 2005 10:36:12 -0400

On Sep 30, 2005, at 9:30 AM, Thom McGrath wrote:
This is the approach I have ended up taking. However, I'm adding images to the menu that come from application icons. One of my application's icons are not loading on the first build. But if the menu ever needs to be re-built, the icon appears every time after.

for (i = 0;i < [cachedSuiteApplications count];i++) {
NSBundle *bundle = [NSBundle bundleWithIdentifier: [cachedSuiteApplications objectAtIndex:i]];
if (bundle != nil) {
item = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:[bundle objectForInfoDictionaryKey:@"CFBundleName"] action:@selector(suiteMenuAction:) keyEquivalent:@""];
[item setTag:i];
[item setIndentationLevel:1];
path = [[bundle resourcePath] stringByAppendingString:@"/"];
path = [path stringByAppendingString:[bundle objectForInfoDictionaryKey:@"CFBundleIconFile"]];
img = [[NSImage alloc] initByReferencingFile:path];
[img setSize:NSMakeSize(16,16)];
[item setImage:img];
[item setTarget:self];
[suiteMenu addItem:item];
[item release];
}
}

I don't see the problem offhand. Does it make a difference if you use -initWithContentsOfFile: instead of -initByReferencingFile:? Is img always non-nil after the init? Is it always the same icon that doesn't load, and is it a boundary case like the first or the last in the list?


--Andy

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Turning NSMenuItem into separator (From: Thom McGrath <email@hidden>)
 >Re: Turning NSMenuItem into separator (From: Andy Lee <email@hidden>)
 >Re: Turning NSMenuItem into separator (From: Andy Lee <email@hidden>)
 >Re: Turning NSMenuItem into separator (From: Thom McGrath <email@hidden>)

  • Prev by Date: Re: XML parser for objective C
  • Next by Date: Re: XML parser for objective C
  • Previous by thread: Re: Turning NSMenuItem into separator
  • Next by thread: NSApp beginsheet beeps!
  • Index(es):
    • Date
    • Thread