Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 在Swift中检测NSViewController外的鼠标按下_Macos_Swift_Nsview_Nsviewcontroller - Fatal编程技术网

Macos 在Swift中检测NSViewController外的鼠标按下

Macos 在Swift中检测NSViewController外的鼠标按下,macos,swift,nsview,nsviewcontroller,Macos,Swift,Nsview,Nsviewcontroller,如何在swift中检测NSViewController外部的鼠标按下事件?我还没有在swift中找到任何例子 谢谢:)使用添加GlobalMonitor或ForeventsMatchingMask记录应用程序之外发生的任何事件 在applicationdFinishLaunching之后将其放入AppDelegate: NSEvent.addGlobalMonitorForEventsMatchingMask(NSEventMask.LeftMouseDownMask, handler: {(e

如何在swift中检测
NSViewController
外部的鼠标按下事件?我还没有在swift中找到任何例子


谢谢:)

使用
添加GlobalMonitor或ForeventsMatchingMask
记录应用程序之外发生的任何事件

applicationdFinishLaunching
之后将其放入
AppDelegate

NSEvent.addGlobalMonitorForEventsMatchingMask(NSEventMask.LeftMouseDownMask, handler: {(event: NSEvent) in

// Do what you have to do here

})

正是我需要的!谢谢,您应该使用本地而不是全局。全局用于窗口外的事件,而本地用于应用程序/窗口内的事件,对吗?