【发布时间】:2016-08-17 14:39:35
【问题描述】:
我正在构建一个状态栏应用,并希望根据用户是单击左还是右来调用不同的操作。这是我目前所拥有的:
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")
}
我的函数没有被调用,我找不到我们的原因。感谢您的帮助!
【问题讨论】:
标签: swift nsstatusitem nsevent nsstatusbar