如果扩展坞可见或未使用 Carbon,您会收到通知。我不知道有什么方法可以在可可中做到这一点。
(我没有测试过这个;它来自代码here http://www.cocoabuilder.com/archive/cocoa/210267-could-keventappsystemuimodechanged-arrive-too-early-to-my-handler.html)
创建您的回调方法:
#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;
}
然后将其放在您想要开始监听通知的任何位置:
InstallApplicationEventHandler(NewEventHandlerUPP(DockChangedHandler), GetEventTypeCount(appEvents), appEvents, 0, NULL);
更多信息:http://developer.apple.com/library/mac/#technotes/tn2002/tn2062.html http://developer.apple.com/library/mac/#technotes/tn2002/tn2062.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)