用户分配的密钥等效项 [英] User assigned key equivalents

查看:85
本文介绍了用户分配的密钥等效项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用状态栏应用程序.我想允许用户将菜单项按键等效项修改为他们自己的首选项.在它是一个非常普遍的功能之前,我已经看到了它的完成. Prefs窗口通常具有一个带有文本字段的区域,用户可以在其中输入特定菜单项的键盘快捷键.

I'm working on a Status Bar App. I'd like to allow the user to modify the menu item key equivalents to their own preferences. I've seen this done before it's a pretty common feature. A prefs window usually has an area with textfields where the user enters their keyboard shortcut for specific menu items.

如何设置文本字段,使其显示修饰键字体? 默认的NSTextfield会忽略修饰符.

How does one setup the textfield so that it displays the modifier key fonts? The default NSTextfield ignores modifiers.

如果有人有一个非常有用的链接,我还没有找到一个显示此功能的示例项目.

Also I have yet to find an example project showing this functionality, if anyone has a link that would be very helpful.

推荐答案

您不妨看一看Shortcut Recorder,它允许用户使用修饰符记录等效键,然后让您检索它们并将其设置为NSMenuItem.

You may wish to take a look at Shortcut Recorder which allows the user to record key equivalents using modifiers and then for you to retrieve them and set them for the NSMenuItem.

一旦用户记录了他们的快捷键/组合键,您就可以访问SRRecorderControlobjectValue属性,该属性具有键代码和修饰符标志的值.

Once the user has recorder their shortcut/key combination you can access the SRRecorderControl's objectValue property which has values for the key code and modifier flags.

https://github.com/Kentzo/ShortcutRecorder

这篇关于用户分配的密钥等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆