简体   繁体   English

OS X应用程序的键盘快捷键视图?

[英]Keyboard shortcut view for OS X application?

I've seen this kind of UI in several different apps: 我已经在几种不同的应用程序中看到过这种UI:

图片

I'm not sure if there's an open source project that does something similar (I've searched all over github but haven't found anything), but I'd like to verify my approach on implementation before getting started (since I'm a cocoa noob). 我不确定是否有一个开源项目执行类似的操作(我在github上进行了搜索,但未找到任何内容),但是我想在开始之前验证实现方法(因为我可可豆)。

I can subclass nstextview, and have the special character grey background as a background. 我可以将nstextview子类化,并使用特殊字符灰色背景作为背景。 Then, on keydown, update that background image to be the appropriate image. 然后,在按下键盘时,将该背景图像更新为适当的图像。 Then, I'll need to do some kind of big switch statement/reverse lookup of the keycode to the string representation of what was pressed and use that. 然后,我将需要对按键代码进行某种大的switch语句/对键码的反向查找,然后使用它。

Does that make sense? 那有意义吗?

There are several open source implementations of this kind of control. 有几种此类控件的开源实现。 Two notable ones are ShortcutRecorder and MASShortcut . 两个值得注意的是ShortcutRecorderMASShortcut Neither of them look exactly like this particular example but it shouldn't be difficult to customize them visually. 它们看起来都不像这个特定示例,但是从视觉上对其进行自定义并不难。 The hard stuff (translating key codes, registering shortcut handlers, etc.) is done for you by these libraries, so they would be a good starting point. 这些库为您完成了艰苦的工作(翻译键码,注册快捷方式处理程序等),因此它们将是一个不错的起点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM