title: Call Action when NSStatusBarButton is right-clicked
body: <p>I am searching for a way to detect whenever the <code>NSStatusBarButton</code> is right-clicked (using Swift) and call an action.</p>
  
  <p>I am currently setting it up this way:</p>
  
  <pre><code>let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-1)
  
  func applicationDidFinishLaunching(aNotification: NSNotification) {
      // Insert code here to initialize your application
      if let button = statusItem.button {
          button.image = NSImage(named: "myImage")
          button.alternateImage = NSImage(named: "myImage")
          button.action = Selector("myAction")
      }
  }
  </code></pre>
  
  <p>I thought of using the <code>button.rightMouseDown(&lt;#theEvent: NSEvent#&gt;)</code> (Because there is no such "alternateAction") but unfortunately I did not manage to come up with something due to the fact that I just started programming Mac apps.</p>
  
  <blockquote>
    <h3>Update:</h3>
    
    <p>While searching for a way to do this I saw some threads telling to subclass a <code>NSView</code> but I don't se how this should work (This could be because I am really new to programming and don't even know how to "subclass"). Still I thought there was some easier way to use this since nearly every <code>statusBar</code> App that I know rects on right-clicks.</p>
  </blockquote>