반응형
🗂 Handling Mouse, Keyboad Events Swift Source Code
override func viewDidLoad() {
super.viewDidLoad()
NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] in
guard let self = self else { return nil }
self.keyDown(with: $0)
return $0
}
NSEvent.addLocalMonitorForEvents(matching: .leftMouseDown) { [weak self] in
guard let self = self else { return nil }
self.mouseDown(with: $0)
return $0
}
}
// MARK: - Event Method
override func keyDown(with event: NSEvent) {
super.keyDown(with: event)
}
override func mouseDown(with event: NSEvent) {
super.mouseDown(with: event)
}
🚀 REFERENCE
반응형
'#컴퓨터 과학 [Computer Science] > 운영체제 (Operating System)' 카테고리의 다른 글
[OS - 🍎 macOS] Parallels 15 (Mac): Updating macOS Catalina Beta to Big Sur Beta [BIErrorDomain error 3] (0) | 2020.06.25 |
---|---|
[OS - 🍎 macOS] DispatchSourceTimer (0) | 2020.04.11 |
[OS - 🍎 macOS] ARC (Automatic Reference Counting) (0) | 2020.03.22 |
[OS - 🍎 macOS] Finder Sync Extensions (0) | 2020.02.28 |
[OS - 🍎 macOS] NSServices (0) | 2020.02.27 |
댓글