右键单击并左键单击菜单栏应用程序

时间:2014-03-07 06:28:00

标签: objective-c menu menubar right-click

我有这个菜单栏应用程序,用于在左键单击时执行操作,并在右键单击时显示菜单。唯一的问题是我不知道该怎么做。有谁能够帮我? 这是启用菜单栏应用程序的代码:

- (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];
}

0 个答案:

没有答案