tags:

views:

30

answers:

1

Hi,

How to handle the menu bar events, that is if i press "quit" or "about" option in the menu bar where the control comes.

Thanks in advance,

+1  A: 

To understand this, you'll need to read up on the responder chain. You'll want to pay particular attention to the section titled "Action Messages" at the bottom of the page I linked. A nil-targetted action gets sent to the First Responder. This is how menu items usually work.

In the case of About or Quit, these actions get sent to the MainMenu.xib's File's Owner, which is your NSApplication instance. These actions are, respectively, -orderFrontStandardAboutPanel: and -terminate:. Since these actions are built into the NSApplication class, you don't have to handle them at all. Just leave the menu items wired as they are.

Joshua Nozzi
My game is not quitting when i press cmd+q in menubar... what may be the problem.
Chandan Shetty SP
There's nowhere near enough information in your question to answer that. Have you checked in Interface Builder (in your MainMenu.nib/xib) to make sure the Quit menu item is actually connected to the -terminate: action of File's Owner?
Joshua Nozzi