Custom NSStatusItem and NSView not reliably receiving NSTrackingEvents

孤街醉人 提交于 2019-12-06 05:33:00

I opened a DTS request to have Apple take a look at this. Here is the response:

...you are using full screen in Xcode when starting your app. I wasn't doing this [before], but I now can reproduce the issue. From what I can tell it only happens when your app is started from full screen mode in Xcode. Your users won't be starting the app this way. This is a problem with AppKit's fullScreen mode, and not necessarily with your code.

I believe you should manage tracking areas only in -[NSView updateTrackingAreas]. For example:

- (void)updateTrackingAreas
{
    if (_trackingArea) {
        [self removeTrackingArea:_trackingArea];
    }

    [super updateTrackingAreas];

    NSTrackingAreaOptions options = (NSTrackingMouseEnteredAndExited |
                                     NSTrackingMouseMoved |
                                     NSTrackingInVisibleRect |
                                     NSTrackingActiveAlways);
    _trackingArea = [[NSTrackingArea alloc] initWithRect:CGRectZero
                                                 options:options
                                                   owner:self
                                                userInfo:nil];
    [self addTrackingArea:_trackingArea];
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!