1

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.

user812376
  • 63
  • 4

2 Answers2

1

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.

Chuck
  • 234,037
  • 30
  • 302
  • 389
  • I ended up contacting Apple and they said the same thing. Use the Accessibility API. As a note for those considering something similar, the Accessibility API can be disabled in System Preferences, so this is not a universal solution. There is apparently a way to do it using AppleScript, but I've not looked into that one as much. The Accessibility API was recommended as the better option. – user812376 Aug 18 '11 at 16:32
  • @user812376: No problem. Regarding AppleScript: It can be used to move the windows, but AFAIK there's no practical way to watch other applications' windows in order to know *when* to move them. The only options I know of for watching other applications' windows are Accessibility and hacking the window server. – Chuck Aug 18 '11 at 17:42
0

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.

fbernardo
  • 10,016
  • 3
  • 33
  • 46