title: menu items disabled in macOS menubar App
body: <p>I'm trying to build a menubar app on macOS.</p>
  
  <p>I can't seem to figure out why some menu items are disabled... Screenshot:</p>
  
  <p><a href="https://i.stack.imgur.com/g0pNA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g0pNA.png" alt="Screenshot of the app"></a></p>
  
  <p>As you can see, the <em>Quit</em> menu item is enabled, and quits the app when clicked. The <em>Preferences</em> item is disabled however.</p>
  
  <h3>My code</h3>
  
  <p><strong><code>AppDelegate.swift:</code></strong></p>
  
  <pre><code>let menuBarItem = NSStatusBar.system().statusItem(withLength: NSSquareStatusItemLength)
  
  func applicationDidFinishLaunching(_ aNotification: Notification) {
      menuBarItem.button?.image = NSImage(named: "MenuBarIcon")
      menuBarItem.menu = MenuBarMenu()
  }
  </code></pre>
  
  <p><strong><code>MenuBarMenu.swift:</code></strong></p>
  
  <pre><code>class MenuBarMenu: NSMenu {
      init() {
          super.init(title: "Menu")
          self.addItem(withTitle: "Preferences...", action: #selector(MenuBarActions.openPreferencesWindow(_:)), keyEquivalent: "")
          self.addItem(NSMenuItem.separator())
          self.addItem(withTitle: "Quit", action: #selector(MenuBarActions.terminate(_:)), keyEquivalent: "")
      }
  
      required init(coder decoder: NSCoder) {
          fatalError("init(coder:) has not been impemented")
      }
  }
  
  class MenuBarActions {
      @objc static func terminate(_ sender: NSMenuItem) {
          NSApp.terminate(sender)
      }
  
      @objc static func openPreferencesWindow(_ sender: NSMenuItem) {
          print("preferences")
      }
  }
  </code></pre>
  
  <p>I am using the exact same way to create both MenuBarItems and the same structure for the selectors, so I am a little confused by this inconsistency. What is the reason this happens and how can I solve this problem?</p>