Erik Sapir
Erik Sapir

Reputation: 24737

NSWindow - show new window that will always stay on top of current window

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?

Upvotes: 7

Views: 7318

Answers (3)

Mrug
Mrug

Reputation: 5023

This worked for me, hope that will be helpful

[self.window makeKeyAndOrderFront:nil];
[self.window setLevel:NSStatusWindowLevel];

Upvotes: 2

spudwaffle
spudwaffle

Reputation: 2925

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.

Upvotes: 5

VenoMKO
VenoMKO

Reputation: 3294

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.

Upvotes: 3

Related Questions