I'm having a weird issue where I'm not receiving keyDown, mouseDown et al in my NSViewController. In fact, instead the Mac beeps (same sound as NSBeep()) when I press a key. I even went as far as replacing the root window of my app with a subclass to see if it was receiving events, which it isn't. Does anybody know what I'm doing wrong?
Asked
Active
Viewed 48 times
0
-
How is your window created and shown? Has it been made "key"? Can it even become key? Is it borderless? – Ken Thomases Jul 05 '17 at 02:01
-
You need to make your view controller the `NSWindowDelegate`, override `viewWillAppear` method and add `view.window?.delegate = self`. another option is to add `NSEvent.addLocalMonitorForEvents(matching: .keyDown)` to your view controller. To silent the purr sound you need to subclass your `NSView` and override the method `performKeyEquivalent(with event: NSEvent)` and return true – Leo Dabus Jul 05 '17 at 02:30
-
https://stackoverflow.com/a/32447474/2303865 – Leo Dabus Jul 05 '17 at 02:32