我有这个菜单栏应用程序,用于在左键单击时执行操作,并在右键单击时显示菜单。唯一的问题是我不知道该怎么做。有谁能够帮我? 这是启用菜单栏应用程序的代码:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
[_aboutWindow orderOut:nil];
}
- (void)awakeFromNib{
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain];
NSBundle *bundle = [NSBundle mainBundle];
statusImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForResource:@"icon" ofType:@"png"]];
statusHighlightImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForResource:@"hicon" ofType:@"png"]];
[statusItem setImage:statusImage];
[statusItem setAlternateImage:statusHighlightImage];
[statusItem setMenu:statusMenu];
[statusItem setHighlightMode:YES];
}
-(void)dealloc{
[statusImage release];
[super dealloc];
}