开发者

Disable keyboard shortcut

I want to disable keyboard shortcut Command+Shift+4 when my Mac OS X application runs开发者_如何学Go. Can anyone tell me how to do it?


You can disable the system keyboard shortcuts with:

#import <Carbon/Carbon.h>

void *oldHotKeyMode = PushSymbolicHotKeyMode(kHIHotKeyModeAllDisabled); 

Make sure that you re-enable them with:

PopSymbolicHotKeyMode(oldHotKeyMode); 

Be careful if you do this, it makes it more difficult to switch away from your app with Cmd+Tab if it is misbehaving so it can mean that if your app misbehaves the user has to power off the system instead of just force quitting your app.

Tested and working with Mac OS X Lion.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜