问题
I want my NSWindow to show new window(s) that will always be on top of current window. they should NOT be on top of other windows.
In addition, they should not move when the original window moves.
How can i do that?
回答1:
Use NSWindow
's addChildWindow:ordered:
or setParentWindow:
method to add the other window as a child of the first window. That window will follow the first window around. See the NSWindow Class Reference.
回答2:
You can set window level to NSFloatingWindowLevel so it always be on top.
To prevent window from covering other applications you can set its level to NSNormalWindowLevel or you can hide it at all. Try to use applicationWillResignActive: method (NSApplicationDelegate Protocol) to remove your window from top. To catch the moment when you shoud bring your window back on top use applicationWillBecomeActive: method.
回答3:
This worked for me, hope that will be helpful
[self.window makeKeyAndOrderFront:nil];
[self.window setLevel:NSStatusWindowLevel];
来源:https://stackoverflow.com/questions/6723578/nswindow-show-new-window-that-will-always-stay-on-top-of-current-window