In a document-based project I am trying to create a status menu. I have a singleton class that builds the status bar, and I am initiating it from an application delegate, as you can see. When I run this, I get no errors, but only an image of the status bar, but no menu drops down. I created the menu in IB. What am I messing up?
Delegate
#import "KBAppDelegate.h"
#import "KBStatusMenu.h"
@implementation KBAppDelegate
@synthesize window = _window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
KBStatusMenu *aStatusItem = [[KBStatusMenu alloc] init];
aStatusItem = [[KBStatusMenu instance] buildStatusItem];
}
@end
.h
#import <Foundation/Foundation.h>
@interface KBStatusMenu : NSObject
{
NSStatusItem *myStatusItem;
NSImage *statusImage;
IBOutlet NSMenu *myStatusMenu;
}
+ (KBStatusMenu *)instance;
- (id)buildStatusItem;
@end
.m
#import "KBStatusMenu.h"
@implementation KBStatusMenu
static KBStatusMenu *gInstance = nil;
+ (KBStatusMenu *)instance
{
@synchronized(self) {
if (gInstance == nil)
gInstance = [[self alloc] init];
}
return(gInstance);
}
- (id)buildStatusItem
{
myStatusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain];
statusImage = [NSImage imageNamed:@"statusNormTemplate.png"];
[myStatusItem setImage:statusImage];
[myStatusItem setHighlightMode:YES];
[myStatusItem setMenu:myStatusMenu];
return myStatusItem;
}
@end