在成功实现了Dave DeLong的DDHotKey之后,我现在想知道是否有可能使热键用户可定义?
应用程序中专门处理HotKey的唯一代码是:
- (IBAction)registerHotKey:(id)sender {
DDHotKeyCenter * c = [[DDHotKeyCenter alloc] init];
[c registerHotKeyWithKeyCode:1 modifierFlags:NSControlKeyMask target:self action:@selector(activateMain:) object:window];
[c release];和
- (IBAction) unregisterHotKey:(id)sender {
DDHotKeyCenter * c = [[DDHotKeyCenter alloc] init];
[c unregisterHotKeyWithKeyCode:1 modifierFlags:NSControlKeyMask];
[c release];
}我认为有必要重写这些部分,但我不确定这是不是真的,如果是真的,我也不确定从哪里开始看。
在我看来,有必要捕获键盘输入并将其保存为string...but,除此之外,我真的不确定如何继续。
发布于 2011-07-27 05:34:11
是的,你可以让它们成为用户可配置的。你需要一些UI让用户自己输入键盘快捷键(我以前用过Shortcut Recorder )。您从该控件获得的信息应该足以传递给DDHotKey注册函数。
https://stackoverflow.com/questions/6834818
复制相似问题