Detect left and right click events on NSStatusItem (Swift)
<p>I’m building a status bar app and want to call different actions depending on if the user clicked left or right. Here’s what I have so far:</p>

<pre><code>var statusItem = NSStatusBar.system().statusItem(withLength: -1)
statusItem.action = #selector(AppDelegate.doSomeAction(sender:))

let leftClick = NSEventMask.leftMouseDown
let rightClick = NSEventMask.rightMouseDown

statusItem.button?.sendAction(on: leftClick)
statusItem.button?.sendAction(on: rightClick)

func doSomeAction(sender: NSStatusItem) {
    print("hello world")
}
</code></pre>

<p>My function is not called and I couldn’t find our why. I appreciate any help!</p>