title: Show NSMenu only on NSStatusBarButton right click?
body: <p>I have the following code: (can be copy-pasted to New macOS project) <br></p>
  
  <pre><code>import Cocoa
  import SwiftUI
  
  @NSApplicationMain
  class AppDelegate: NSObject, NSApplicationDelegate {
      var statusBarItem: NSStatusItem!
  
      func applicationDidFinishLaunching(_ aNotification: Notification) {
  
          let statusBar = NSStatusBar.system
          statusBarItem = statusBar.statusItem(
              withLength: NSStatusItem.squareLength)
          statusBarItem.button?.title = ""
  
          // Setting action
          statusBarItem.button?.action = #selector(self.statusBarButtonClicked(sender:))
          statusBarItem.button?.sendAction(on: [.leftMouseUp])
  
          let statusBarMenu = NSMenu(title: "Status Bar Menu")
          statusBarMenu.addItem(
              withTitle: "Order an apple",
              action: #selector(AppDelegate.orderAnApple),
              keyEquivalent: "")
  
          statusBarMenu.addItem(
              withTitle: "Cancel apple order",
              action: #selector(AppDelegate.cancelAppleOrder),
              keyEquivalent: "")
  
          // Setting menu
          statusBarItem.menu = statusBarMenu
      }
  
      @objc func statusBarButtonClicked(sender: NSStatusBarButton) {
          let event = NSApp.currentEvent!
  
          if event.type ==  NSEvent.EventType.rightMouseUp {
              print("Right click!")
          } else {
              print("Left click!")
          }
      }
  
      @objc func orderAnApple() {
          print("Ordering a apple!")
      }
  
  
      @objc func cancelAppleOrder() {
          print("Canceling your order :(")
      }
  
  }
  
  </code></pre>
  
  <p><strong>Actual behaviour</strong>: Menu opens on both left and right click, statusBarButtonClicked is not triggered.<br>
  After removing this line:</p>
  
  <pre><code>statusBarItem.menu = statusBarMenu
  </code></pre>
  
  <p>statusBarButtonClicked triggers on left click, menu doesn't show up (as expected)<br>
  <br>
  <strong>Desired behaviour</strong>: Menu opens on right click, on left click menu doesn't open, action is triggered.<br> How do I achieve it?</p>
  
  <h2>EDIT</h2>
  
  <p>I managed to achieve desired behavior with help of @red_menace comment:</p>
  
  <pre><code>import Cocoa
  import SwiftUI
  
  @NSApplicationMain
  class AppDelegate: NSObject, NSApplicationDelegate {
      var statusBarItem: NSStatusItem!
      var menu: NSMenu!
  
      func applicationDidFinishLaunching(_ aNotification: Notification) {
  
          let statusBar = NSStatusBar.system
          statusBarItem = statusBar.statusItem(
              withLength: NSStatusItem.squareLength)
          statusBarItem.button?.title = ""
  
          // Setting action
          statusBarItem.button?.action = #selector(self.statusBarButtonClicked(sender:))
          statusBarItem.button?.sendAction(on: [.leftMouseUp, .rightMouseUp])
  
          let statusBarMenu = NSMenu(title: "Status Bar Menu")
          statusBarMenu.addItem(
              withTitle: "Order an apple",
              action: #selector(AppDelegate.orderAnApple),
              keyEquivalent: "")
  
          statusBarMenu.addItem(
              withTitle: "Cancel apple order",
              action: #selector(AppDelegate.cancelAppleOrder),
              keyEquivalent: "")
  
          // Setting menu
          menu = statusBarMenu
      }
  
      @objc func statusBarButtonClicked(sender: NSStatusBarButton) {
          let event = NSApp.currentEvent!
  
          if event.type ==  NSEvent.EventType.rightMouseUp {
              statusBarItem.popUpMenu(menu)
          } else {
              print("Left click!")
          }
      }
  
      @objc func orderAnApple() {
          print("Ordering a apple!")
      }
  
  
      @objc func cancelAppleOrder() {
          print("Canceling your order :(")
      }
  
  }
  </code></pre>
  
  <p>But Xcode says that <code>openMenu</code> func is deprecated in 10.14 and tells me to <code>Use the menu property instead</code>. Is there I way to achieve desired behaviour with new API?</p>