我正在尝试在Swift中使用CGEventTapCreate等来捕获按键。我想这样做,以便当我的child使用Mac程序时,我可以限制哪些键可以做某事。我明白我需要启用辅助技术才能让CGEventTap工作我无法理解我需要在Swift中做什么才能获得调用中的最终参数。本质上,我不理解quartz事件documentation的部分文档特别是描述的最终参数refcon:Apointertouser-defineddata.Thispointerispassedintothecallbackfunctionspecifiedinthecallbackparameter.这是我的代码缺少调用
我的应用程序的功能之一是检测keyDown事件并对某些特定键进行操作。所以,我使用CGEventTapCreate来解决我的问题,我的代码是这样的:iflettap=CGEventTapCreate(.CGHIDEventTap,.HeadInsertEventTap,.Default,CGEventMask(1此外,我处理流程信任的方式如下:letoptions=[kAXTrustedCheckOptionPrompt.takeUnretainedValue()asNSString:false]letprocessTrusted=AXIsProcessTrustedWithOptio
有没有人设法让这个函数在Swift中工作?这是去年的引用SO帖子:UsingCGEventTapCreateTroublewithparametersinSwiftApple文档:https://developer.apple.com/library/prerelease/mac/documentation/Carbon/Reference/QuartzEventServicesRef/index.html#//apple_ref/c/func/CGEventTapCreateCGEventTapCallBack的定义如下:typealiasCGEventTapCallBack=CFu