Using CGEventTapCreate Trouble with parameters in Swift

百般思念 提交于 2019-12-06 07:57:20
james_alvarez

Bit of a while ago, but I think when you look at the type of CGEventTapCallback, you see that it is a CFunctionPointer:

typealias CGEventTapCallBack = CFunctionPointer<((CGEventTapProxy, 
CGEventType, CGEvent!, UnsafeMutablePointer<Void>) -> Unmanaged<CGEvent>!)>

At the moment you can't create these in Swift, so you have to dip into objective-c, create a function there, which can then call an equivalent function in Swift, see here:

Objective-C Wrapper for CFunctionPointer to a Swift Closure

I ended up writing the whole of this stuff in Objective-C...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!