开发者

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:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜