title: How can I call a function/action when a statusItem is clicked?
body: <p>I have this code that opens up a popover element at the "sender" location, i.e. the button that was pressed. How can I make this function call when a statusItem is clicked, so that the popover comes down from the status/menu bar?</p>
  
  <pre><code>@IBAction func togglePopover(sender: AnyObject) {
      if !(popoverIsOpen) {
          myPopover.showRelativeToRect(sender.bounds, ofView: popoverButton, preferredEdge: NSRectEdge(3))
          popoverIsOpen = true
      }
      else {
          myPopover.close()
          popoverIsOpen = false
      }
  }
  </code></pre>
  
  <p>I am currently using <code>NSPopover</code> and <code>NSStatusItem</code>.</p>
  
  <p><strong>edit:</strong> The changelog for Xcode 6 beta 4 added <code>NSStatusItem.button</code> and softly deprecated the previous form of calls like <code>NSStatusItem.action</code>, <code>NSStatusItem.title</code>, <code>NSStatusItem.target</code>, etc. </p>
  
  <p>The documentation now reads </p>
  
  <blockquote>
    <p><code>NSStatusItem.button</code></p>
    
    <blockquote>
      <p>The button that is displayed in the status bar. This is created automatically on the creation of the StatusItem. Behavior customization for the button, such as image, target/action, tooltip, can be set with this property.</p>
    </blockquote>
  </blockquote>