Hi,
I am creating a status bar app that hides the desktop. I am trying to get it to run a function that checks if there is an external monitor connected and it will the update the NSOn/OffState of a menu item. I have the function working but I would like it to open the menu at the same time. At the moment i can only get either the function to run with no menu or the menu to pop up but it won't run the function.
If I // out the statusItem.menu = JDO menu the function runs but when i leave it in it just opens the menu but doesn't run the function
Can anyone help and point me in the right direction?
Thanks
Miles
I am creating a status bar app that hides the desktop. I am trying to get it to run a function that checks if there is an external monitor connected and it will the update the NSOn/OffState of a menu item. I have the function working but I would like it to open the menu at the same time. At the moment i can only get either the function to run with no menu or the menu to pop up but it won't run the function.
Code:
func applicationDidFinishLaunching(_ aNotification: Notification) {
showDesktopMenuItem.state = NSOnState
statusItem.menu = JDOMenu
if let button = statusItem.button {
button.image = NSImage(named: "JDOIcon")
button.action = #selector(queryState(sender:))
button.target = self
}
}
func queryState() {
//Checks external monitor state
}
If I // out the statusItem.menu = JDO menu the function runs but when i leave it in it just opens the menu but doesn't run the function
Can anyone help and point me in the right direction?
Thanks
Miles