开发者

Constraining window positions in other applications in Cocoa?

开发者 https://www.devze.com 2023-03-15 10:18 出处:网络
I\'m relatively new to Cocoa development.I\'m developing on Snow Leopard.I have a scenario in mind and I\'m curious if the API supports it.I\'ve not been able to find anything about it, so I assume it

I'm relatively new to Cocoa development. I'm developing on Snow Leopard. I have a scenario in mind and I'm curious if the API supports it. I've not been able to find anything about it, so I assume its not possible. But I'm happy to be proved wrong.

Suppose I write an application that lives at the top of the screen just below the menu bar. The window floats, so it is always on top. This can be annoying, so one thing I had in开发者_运维问答 mind was constraining other windows (especially those in other applications) so that they are below my application. Is there something in the API that would allow me to do that? To specify a maximum origin for all windows (except mine)?

Thanks.


There's no real supported way to do this. You could achieve something similar using the Accessibility API. You'd have to watch for window-moved notifications and shove the window back into the visibile area.


I don't think you can do that, you see, one of the cool things of a window's based UI is that you can stack Windows on top of others, in a desktop metafore.

Now, what you can do is a always on top window, using NSScreenSaverWindowLevel as the NSWindow level. One nice trick you can do is [window setLevel: NSScreenSaverWindowLevel+1], and it set's your window above the screensaver level.

0

精彩评论

暂无评论...
验证码 换一张
取 消