0
我創建了一個NSStatusBarItem
和右鍵彈出菜單的(程序生成)NSMenu
:斯威夫特:NSStatusItem之後剩下的突出右鍵單擊
let statusBarItem = NSStatusBar.system().statusItem(withLength: -1)
statusBarItem.action = #selector(AppDelegate.statusBarItemAction(sender:))
let menu = NSMenu()
var menuItem = NSMenuItem()
menuItem.action = #selector(AppDelegate.customItemAction)
menu.addItem(menuItem)
func statusBarItemAction(sender: NSStatusItem) {
let mouseEvent = NSEvent.pressedMouseButtons()
if mouseEvent == 2 {
// right click
lxStatusBarItem.popUpMenu(menu)
}
}
func customItemAction() {
// do something
}
一切工作正常,除了statusBarItem
保持customItemAction
後強調被稱爲:
我該如何解決這個問題?