How can I make a fullscreen overlay on the OS X desktop?

穿精又带淫゛_ 提交于 2019-12-05 02:22:55

问题


I want to make some kind of drawable surface that exists beneath the mouse cursor but above everything else rendered on the desktop. I am trying to create a "trail" behind the mouse.

How can I do this in Cocoa and Objective-C?


回答1:


You need to subclass NSWindow to create a borderless window and set its window level to something like NSScreenSaverWindowLevel - 1.

- (id)initWithContentRect:(NSRect)contentRect 
                styleMask:(NSUInteger)aStyle
                  backing:(NSBackingStoreType)bufferingType
                    defer:(BOOL)flag
{
    self=[super initWithContentRect:contentRect 
                          styleMask:NSBorderlessWindowMask 
                            backing:bufferingType
                              defer:flag];

    if(self!=nil)
    {
        [self setHasShadow:NO];
        [self setOpaque:NO];
        [self setBackgroundColor:[NSColor clearColor]];
        [self setLevel:NSScreenSaverWindowLevel - 1];
    }
    return self;
}


来源:https://stackoverflow.com/questions/7217931/how-can-i-make-a-fullscreen-overlay-on-the-os-x-desktop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!