Cocoa - 热键的键盘参考号;有详细说明这些的文档吗?

发布于 2024-09-06 08:56:04 字数 156 浏览 2 评论 0原文

我目前正在编写一个具有热键功能的应用程序,我已经阅读了一些内容,并惊讶地发现这一切都是通过旧的 Carbon API 完成的。然而,也许最大的困境是我无法计算它所需的“键盘参考号”。

我见过的唯一一个可以实现这一点的应用程序(ASyncKey)将不再工作,因为它是一个经典应用程序。

I'm currently coding an app that has hotkey functionality, I've done some reading and was surprised to see it is all done via an old Carbon API. However, perhaps the biggest dilemma is I am unable to calculate the "Keyboard Reference Number"s it requires.

The only app I have seen that makes this possible (ASyncKey) won't work anymore as it was a Classic app.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

放我走吧 2024-09-13 08:56:04

我会尽可能使用 Events.h 中的常量。

如果您确实需要参考文档,可以在 Macintosh 内部:文本。虽然它是为 ADB 键盘编写的,但今天仍然准确。

您会发现地图网页版的美式键盘难以阅读;请参阅 PDF(文档第 1033 页,书籍第 C-5 页),或使用 这个方便的裁剪

另一种解决方案是使用Many Tricks 提供的按键代码来显示您按下的任何键的按键代码。

I'd use the constants in Events.h whenever possible.

If you really want a reference document, there is a reference of the key codes for a US keyboard in Inside Macintosh: Text. While it was written for ADB keyboards, it's still accurate today.

You'll find the maps of the US keyboards in the web-page version hard to read; either consult the PDF (document page 1033, book page C-5), or use this handy crop from it.

Another solution is to use Key Codes, by Many Tricks, to display the key code for any key you press.

扛起拖把扫天下 2024-09-13 08:56:04

虽然创建热键的 API 是 Carbon API,但我不一定将其称为“旧”API;它已更新为适用于 64 位应用程序,并且是 今年的一场会议的主题WWDC(会议#145)。

至于你的问题,我不太清楚你的意思。我厌倦了尝试处理(我认为是)像 PTHotKey 这样的包装器的类膨胀,所以我编写了自己的包装器。你可以仔细阅读 Github 上的源代码: http://github.com/davedelong/DDHotKey 希望这会帮助您弄清楚发生了什么事。

编辑 键代码是您指示要将代码绑定到哪个键的方式。这些键代码是“虚拟”键代码,可以通过以下两种方式之一获取它们:

  1. 仔细阅读 HIToolbox/Events.h 并找到所需的键
  2. -[NSEvent keyCode]

甚至像 ShortcutRecorder 这样的项目使用这两种方法之一。我不知道还有其他人。

While the API to create hotkeys is a Carbon API, I wouldn't necessarily call it an "old" API; it's been updated to work for 64-bit apps and was the topic of one of the sessions at this year's WWDC (Session #145).

As for your question, I'm not quite sure what you mean. I got sick of trying to deal with (what I thought was) the class bloat of wrappers like PTHotKey, so I wrote my own. You can peruse the source on Github: http://github.com/davedelong/DDHotKey Hopefully that will help you figure out what's going on.

edit Key codes are how you indicate which key you want to tie your code to. These key codes are the "virtual" key codes, and they can be acquired in one of two ways:

  1. Perusing HIToolbox/Events.h and finding which key you want
  2. Extract it from -[NSEvent keyCode]

Even projects like ShortcutRecorder use one of these 2 approaches. I'm not aware of any others.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文