Handle key events in a PHContentEditingController for Cocoa Photo Editing Extensions

Hello. How to receive keyboard events in PHContentEditingController on macOS?

When extension is active tapping any key will result in Funk sound.

First i tried to override keyDown in my subclass of PHContentEditingController, which does nothing.

I also tried override keyDown in my subclass of NSView for my subclass of PHContentEditingController.

Then i followed instructions from WWDC "Advances in macOS Security" session and implemented Input monitoring permissions request via CGEvent.tapCreate which only partially works. My extension now listed in System security / Privacy / Input Monitoring but it's impossible to turn it on. On each attempt to enable system fires alert with request to relaunch the app but does nothing. When alert disappear extension persist unchecked.

My goal is to provide keyboard shortcuts for various task in Photo Editing Extension. How i can achieve that?

Handle key events in a PHContentEditingController for Cocoa Photo Editing Extensions
 
 
Q