반응형
🗂 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
Handling Mouse Events
Handling Mouse Events Mouse events are one of the two most frequent kinds of events handled by an application (the other kind being, of course, key events). Mouse clicks—which involve a user pressing and then releasing a mouse button—generally indicate sel
developer.apple.com
NSResponder - AppKit | Apple Developer Documentation
Informs the receiver that the user has pressed or released a modifier key (Shift, Control, and so on).
developer.apple.com
반응형
'#컴퓨터 과학 [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 |
댓글