Reputation: 365
osx- I have two windows, I initially set the first window be key window, then set the second window to be key window, then I call [NSApp activateIgnoringOtherApps:Yes]. And I print [[NSApplication sharedApplication] orderedWindows];
I found, if the first window closed, the orderedWindows will be only the second Window.
But if the first window is still open, even if I had made the second window be key and main, but the orderedWindows will be {firstWindow, secondWindow}
But I want the second window be the front the one.
I also make the secondWindow do like this:
[captureWindow setLevel:NSStatusWindowLevel + 2];
[captureWindow setReleasedWhenClosed:YES];
[captureWindow setAcceptsMouseMovedEvents:YES];
[captureWindow setMovableByWindowBackground:NO];
[captureWindow makeKeyAndOrderFront:self];
[captureWindow orderFrontRegardless];
[captureWindow orderFront:self];
[captureWindow makeKeyWindow];
[captureWindow makeMainWindow];
[NSApp activateIgnoringOtherApps:YES];
But when [NSApp activateIgnoringOtherApps:YES]; once executed, if the first window is still on screen, then the windowOrdered will be {firstWindow, secondWindow}, so I thinks the orderFront is not worked?
Upvotes: 1
Views: 899
Reputation: 299575
Neither "key" nor "main" is related to ordering. If you want to make a window ordered front, then the method is [NSWindow orderFront:]
. There is a convenience method that is often used to do both: [NSWindow makeKeyAndOrderFront:]
.
Upvotes: 1