NSWindow 在桌面图标之上绘制
我正在编写一个应用程序,希望在桌面图标(Mac OSX 10.7 Lion)之上绘制一个基本的 NSWindow。
NSWindow *systemInfoWindow = [[NSWindow alloc] initWithContentRect:frame
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO];
systemInfoWindow.delegate = self;
[systemInfoWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
[systemInfoWindow setBackgroundColor:backgroundColorSpace];
[systemInfoWindow makeKeyAndOrderFront:NSApp];
[systemInfoWindow setLevel:kCGDesktopIconWindowLevel];
这部分代码工作得很好,NSWindow 绘制在图标之上。 但是如果我在两个空间之间切换,我的 NSWindow 就会停留在图标后面。
/* === 更新 === */ 我认为我的窗户水平有问题。为了更好地理解,我上传了两个屏幕截图。 空间 1 - 窗口保持在图标顶部,就像我想要的那样 http://dl.dropbox.com/u/1503795/Space1.png
空格 2 - 窗口位于桌面图标后面。他们也应该保持领先地位 http://dl.dropbox.com/u/1503795/Space2.png
我发现了另一个问题。如果我激活应用程序并停留在第一个空间,一切看起来都像我的第一个屏幕截图一样好。如果我选择桌面上的文件,窗口也会跳到后面: 抱歉,无法发布其他屏幕截图
我希望我的问题更容易理解。
我不知道如何解决这个问题。有人有想法吗? 谢谢!
I'm writing an application that is looking to draw a basic NSWindow on top of the Desktop icons (Mac OSX 10.7 Lion).
NSWindow *systemInfoWindow = [[NSWindow alloc] initWithContentRect:frame
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO];
systemInfoWindow.delegate = self;
[systemInfoWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
[systemInfoWindow setBackgroundColor:backgroundColorSpace];
[systemInfoWindow makeKeyAndOrderFront:NSApp];
[systemInfoWindow setLevel:kCGDesktopIconWindowLevel];
This part of code works quite well and the NSWindow gets draw on top of the icons.
But if I switch between two spaces my NSWindow stay behind the icons.
/* === Update === */
I think i have problems with my window Level. For better understanding I have uploaded two Screenshots.
Space 1 - window stays like I want on top of the Icons
http://dl.dropbox.com/u/1503795/Space1.png
Space 2 - the window is behind the Desktop icons. They should also stay on top
http://dl.dropbox.com/u/1503795/Space2.png
A further problem I found. If I activated the App and stay on the first Space and everything looks good like on my first Screenshot. If I select the Files on the Desktop the window also jumps to the back:
Sorry, can`t post a nother Screenshot
I hope my problem is a bit more understandably.
I dont`t know how to fix this. Has anybody an idea?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要注册空间更改通知:
然后您可以响应通知并更新窗口:
You probably need to register for the space change notification:
You can then respond to the notification and update your window: