在 Swift 中检测到 NSViewController 外的鼠标按下
Detect mouse down outside NSViewController in Swift
如何检测 swift 中 NSViewController
外的鼠标按下事件?我还没有在 swift 中找到任何例子......
谢谢:)
使用 addGlobalMonitorForEventsMatchingMask
记录在您的应用之外发生的任何事件。
在applicationDidFinishLaunching
之后将其放入AppDelegate
:
NSEvent.addGlobalMonitorForEventsMatchingMask(NSEventMask.LeftMouseDownMask, handler: {(event: NSEvent) in
// Do what you have to do here
})
如何检测 swift 中 NSViewController
外的鼠标按下事件?我还没有在 swift 中找到任何例子......
谢谢:)
使用 addGlobalMonitorForEventsMatchingMask
记录在您的应用之外发生的任何事件。
在applicationDidFinishLaunching
之后将其放入AppDelegate
:
NSEvent.addGlobalMonitorForEventsMatchingMask(NSEventMask.LeftMouseDownMask, handler: {(event: NSEvent) in
// Do what you have to do here
})