I Will do my best to explain. I'm currently creating a little tool that rests on the status bar of the mac, I want to enter in the setting of the tool by pressing right-click on the element shown on the status bar. Like this
Currently, I can open the application by clicking on the tool, but how do I open a menù setting with a right-click?
Until now this is the code that is opening the app
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate { //MAIN
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
func applicationDidFinishLaunching(_ aNotification: Notification) {// Insert code here to initialize your application
statusItem.button?.title = "∞"
statusItem.button?.target = self
statusItem.button?.action = #selector(showSetting)
let storyboard = NSStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateController(withIdentifier: "ViewController") as? ViewController
vc?.automaticRefresh()
vc?.beginning()
}
@objc public func showSetting() { //THIS IS NOT REALLY THE SETTING BUT JUST THE APPLICATION ITSELF
let storyboard = NSStoryboard(name: "Main", bundle: nil) //QUI VADO A FARE IN MODO DI POTER CHIAMARE IL MIO VIEW CONTROLLER
let vc = storyboard.instantiateController(withIdentifier: "ViewController") as? ViewController
let popoverView = NSPopover()
popoverView.contentViewController = vc
popoverView.behavior = .transient
popoverView.show(relativeTo: statusItem.button!.bounds, of: statusItem.button!, preferredEdge: .maxY)
vc?.printCurrentState()
}
}