问题描述
我使用函数RegisterEventHotKey(),当我尝试注册Cmd + C或Cmd + V,我注意到在finder中的复制和粘贴不工作。
I use function RegisterEventHotKey() and when I try registering Cmd + C or Cmd + V, I notice that copy and paste in finder doesn't work.
我插入参数inOptions = 0到函数RegisterEventHotKey(),所以它应该是非排他性的,但为什么finder似乎不收到这个热键?
I insert parameter inOptions = 0 to function RegisterEventHotKey() so it should non-exclusiv but why finder seem not to receive this hot key?
EventTypeSpec eventType;
eventType.eventClass=kEventClassKeyboard;
eventType.eventKind=kEventHotKeyPressed;
InstallApplicationEventHandler(&MyHotKeyHandler,1,&eventType,(void *)self,NULL);
EventHotKeyID gMyHotKeyID;
NSInteger keycode = 8; // 'C'
UInt32 modkey=0;
modkey+=cmdKey;
RegisterEventHotKey((int)keycode, modkey, gMyHotKeyID,
GetApplicationEventTarget(), 0, &hotkeyRef);
//
OSStatus MyHotKeyHandler(EventHandlerCallRef nextHandler,EventRef theEvent,
void *userData)
{
NSLog(@"test hot key");
return eventNotHandledErr;
}
这是代码。当我点击cmd + C,它显示日志测试热键,但finder没有复制所选文件。
Here is the code. When I click cmd+C, it show log "test hot key" but finder did not copy selected files.
*我的应用程序是代理。
*My application is agent. has menu bar and always run in the background.
推荐答案
它不工作,因为当你安装一个热键处理程序, em>您替换每个应用程序中该组合键的默认功能。
It doesn't work because when you install a hot key handler, you replace the default functionality of that key combination in every app.
这篇关于为什么复制和粘贴在finder不工作,当我使用RegisterEventHotKey(Cocoa)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!