开发者

Using DDHotKey to create user-definable Hot-Key in my Cocoa Application

Having successfully implemented Dave DeLong's DDHotKey I'm now wondering if it's possible to make the hot-key user definable?

The only code in the app that deals specifically with the HotKey is:

- (IBAction)registerHotKey:(id)sender {
DDHotKeyCenter * c = [[DDHotKeyCenter alloc] init];
[c registerHotKeyWithKeyCode:1 modifierFlags:NSControlKeyMask target:self action:@selector(activateMain:) object:window];
[c release];

and

- (IBAction) unregisterHotKey:(id)sender {
DDHotKe开发者_如何学PythonyCenter * c = [[DDHotKeyCenter alloc] init];
[c unregisterHotKeyWithKeyCode:1 modifierFlags:NSControlKeyMask];
[c release];
}

I'm thinking that it would be necessary to re-write those sections but I'm not sure if that's true, and if it is true I'm not sure where to begin looking.

It seems to me that it would be necessary to capture keyboard input and perhaps save it as a string...but beyond that I'm really unsure as to how to proceed.


Yep, you can make them user-configurable. You'll need some sort of UI for the user to type a keyboard shortcut themselves (I've used Shortcut Recorder in the past). The info you get from that control should be sufficient to pass to the DDHotKey registration functions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜