How to block/redirect global keyboard events in cocoa app
I have setup global keyboard trap using following code:
self.machPortRef = CGEventTapCreate(kCGSessionEventTap,
kCGTailAppendEventTap,
kCGEventTapOptionDefault,
CGEventMaskBit(kCGEventKeyUp),
(CGEventTapCallBack)eventTapFunction,
开发者_如何学运维 self);
How can i block/redirect keydown events of front most active window in my cocoa app. I tried to return NULL in eventTapFunction, but it didn't block the event.
Thanks,
Subclass NSApplication
, and override -sendEvent:
精彩评论