tags:

views:

21

answers:

1

I am using notification to get control when menu items clicked...

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification 
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuChangedItem:) name:NSMenuWillSendActionNotification object:nil];
}

-(void) menuChangedItem :(NSNotification *)inSender
{
    NSDictionary *dict = [inSender userInfo];
    NSMenu *menu = [dict objectForKey:@"MenuItem"];

    NSLog(@"Testing");
}

In menuChangedItem method, is it possible to know which menu item is clicked(about, quit ,hideall etc).

Thanks in advance.

A: 

Take a look at the documentation:

The userInfo dictionary contains the following information:
@"MenuItem" - The menu item that was chosen.

Try the following out:

NSMenuItem *item = [dict objectForKey:@"MenuItem"];
NSLog(@"%@", item);
Georg Fritzsche