当码头显示或隐藏时的事件 [英] Events when dock is showing or hiding
本文介绍了当码头显示或隐藏时的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当Dock显示或隐藏时,如何获取活动?
How can I get events when the Dock is showing or hiding?
推荐答案
可见或不使用碳。我不知道在Cocoa有什么办法。
You can get a notification if the dock is visible or not using Carbon. I do not know of any way to do it in Cocoa.
(我没有测试过,它是从代码此处)
(I haven't tested this; it's from the code here)
创建回调方法:
#import <Carbon/Carbon.h>
static const EventTypeSpec appEvents[] = {
{ kEventClassApplication, kEventAppSystemUIModeChanged }
};
OSStatus DockChangedHandler(EventHandlerCallRef inCallRef, EventRef event, void *userData) {
OSStatus status = eventNotHandledErr;
switch(GetEventClass(event)) {
case kEventClassApplication: {
SystemUIMode *outMode;
SystemUIOptions *outOptions;
GetSystemUIMode(outMode, outOptions);
status = noErr;
}
break;
default:
return;
}
/*Insert whatever you want to do when you're notified of a dock change*/
return status;
}
然后把它放在任何你想开始监听的地方:
And then put this wherever you want to start listening for the notification:
InstallApplicationEventHandler(NewEventHandlerUPP(DockChangedHandler), GetEventTypeCount(appEvents), appEvents, 0, NULL);
更多信息: http://developer.apple.com/library/mac/#technotes/tn2002/tn2062.html
这篇关于当码头显示或隐藏时的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文