简体   繁体   中英

Constraining window positions in other applications in Cocoa?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM