• 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
NSStatusItem:setImage - Icon not displaying
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSStatusItem:setImage - Icon not displaying


  • Subject: NSStatusItem:setImage - Icon not displaying
  • From: James Bush <email@hidden>
  • Date: Tue, 2 Aug 2005 21:52:25 -0700

My application puts a menu (NSMenu) in the system status bar (NSStatusBar). I can set the title of the menu to any string value (NSStatusItem:setTitle), but cannot set the title to an image (NSStatusItem:setImage). Here's the code:

- (void)awakeFromNib
{
NSImage *menuImage = [[NSImage alloc] initWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"image.png" ofType:@"png"]];
NSStatusBar *bar = [NSStatusBar systemStatusBar];
theItem = [bar statusItemWithLength:NSVariableStatusItemLength];
[theItem retain];
[theItem setImage:menuImage];
[theItem setHighlightMode:YES];
[theItem setMenu:theMenu];
}


This code compiles without error or warning. When the build is run, the menu can be displayed by clicking the location where the image file should be.

The problem could be unrelated to the code, as well. For example:
1. Perhaps I've imported the image file into the project incorrectly. Maybe it's not in the right location inside the project folder or is in the wrong group. I cannot find decent documentation on how to import images for use within your application.
2. Perhaps the image file is in the correct location in the project folder (and in the right group), but the URL is not correctly specified.


I'm tapped out on this one. None of the books I've bought, Apple's documentation, Google and about 5 Cocoa Dev web sites have an answer that works.

Thanks!
_______________________________________________
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


  • Follow-Ups:
    • Re: NSStatusItem:setImage - Icon not displaying
      • From: John Stiles <email@hidden>
  • Prev by Date: NSOutlineView and the trash can, take 2
  • Next by Date: Re: NSOutlineView and the trash can, take 2
  • Previous by thread: Re: NSOutlineView and the trash can, take 2
  • Next by thread: Re: NSStatusItem:setImage - Icon not displaying
  • Index(es):
    • Date
    • Thread