Cocoa global shortcuts?

后端 未结 2 1483
无人及你
无人及你 2021-02-02 00:44

I want to create a global shortcut for my app. I\'ve used the \'cool new way\' of doing this with the addGlobalMonitorForEventsMatchingMask method. The problem is, my events don

2条回答
  •  走了就别回头了
    2021-02-02 01:13

    addGlobalMonitorForEventsMatchingMask: is not a suitable replacement for the existing Carbon Hotkey API for all sorts of reasons; it's horribly inefficient, for one. And from the docs:

    ... you can only observe the event; you cannot modify or otherwise prevent the event from being delivered to its original target application.

    and

    Key-related events may only be monitored if accessibility is enabled or if your application is trusted for accessibility access

    The Hotkey API is still the only way to implement global shortcut in OS X. But unlike many Carbon APIs, the Hotkey API is available to 64-bit apps.

提交回复
热议问题