Can't enable menu item (Preferences...) why?

Discussion in 'Mac Programming' started by Xino, Sep 23, 2008.

  1. Xino macrumors member

    Sep 5, 2008
    I've created a project and created two windows (main window and preferences window). In the menu i've a menu item called "preferences..." and the goal purpose is when I click on the menu item, the window preferences opens.

    The problem is that I can't enable the menu item, it remains disable even when I add an action and assign it to the menu item via Interface Builder. I've read some pages on the internet describing how to enable a menu item; simply by assign the menu item to an action... why isn't it working then?

    I've added the action to the Application class and exported the class files into my Xcode project.

    Thanks for your help :)
  2. whooleytoo macrumors 604


    Aug 2, 2002
    Cork, Ireland.
    That sounds right, presumably you've saved the project in IB before rebuilding?

    Can't think of anything wrong, feel free to post the project up here if you want us to take a look at it. (By the sounds of it, you don't have enough done yet that we can steal! ;) )
  3. kainjow Moderator emeritus


    Jun 15, 2000
    My guess is this is your problem. You have added the IBAction methods to an NSApplication subclass, and then in IB you've connected the menu item's action to File Owner, which you may or may not have set as your NSApplication subclass. However, this won't work because File Owner in MainMenu.nib doesn't become the class you assign it. It's always the class that is set in Info.plist PrincipleClass, which unless you've changed it, is NSApplication.

    The proper way of connecting menu items is through an application controller object that is created separately in the nib. Subclass NSObject, add your actions there, and create it in the nib and connect it to the menu items.

Share This Page