开发者

Handling menu events in cocoa

How to handle the menu bar events, that is if i press "quit" or "about" option in 开发者_C百科the menu bar where the control comes.

Thanks in advance,


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜