I have a simple cocoa coredata statusbar application with Xcode 4.6.2.
Here in my AppController.h
i have
@interface AppController : NSObject
@property NSStatusItem *statusItem;
@property IBOutlet NSMenu *statusMenu;
In my AppController.m
:
@synthesize statusItem = statusItem;
@synthesize statusMenu = statusMenu;
-(void)awakeFromNib{
statusItem = [[NSStatusBar systemStatusBar]statusItemWithLength:NSVariableStatusItemLength];
statusItem.menu = statusMenu;
}
then, in my AppDelegate.m
there is a function:
#import "AppController.h"
-(IBAction)someAction:(id)sender{
//code to do something
AppController *x = [[AppController alloc]init];
[x.statusMenu cancelTracking];
}
I want to close the menu via a button that performs an action inside a custom view of a NSMenuItem (from Connection Inspector->Outlets->view ctrl+drag to the button). I cannot select 2 different sent actions for a NSButton, so i have to close the menu declared in AppController class from the IBAction someAction that is in AppDelegate class. How to do it? The code i've posted doesn't work. Thanks in advance