在 `NSEventTap` 中返回我自己创建的 `CGEvent`

Returning a `CGEvent` of my own creation in `NSEventTap`

CGEventTapCallBack 的文档 here 状态:

CGEventRef event The incoming event. This event is owned by the caller, and you do not need to release it.

如果我想吃掉这个事件会怎样,return NULL?我应该 CFRelease 自己吗?

同样,如果我想用我自己创建的事件替换它,我应该 CFRelease 传入事件和 CFRetain 新创建的事件吗?

或者我是否只能就地修改收到的 CGEvent 的内容?确实是这样吗,有没有 API-call 我可以使用热插拔?

CGEventTapCallBack 的文档中复制(问题中的 link):

Discussion

If the event tap is an active filter, your callback function should return one of the following:

  • The (possibly modified) event that is passed in. This event is passed back to the event system.

  • A newly-constructed event. After the new event has been passed back to the event system, the new event will be released along with the original event.

  • NULL if the event passed in is to be deleted.

新活动将与原活动一起发布。原活动不放新活动不放