Reputation: 4107
In my application I have 4-5 windows on screen simultaneously. Sometimes while working some of the windows can go back behind some other app's windows (behind xcode or safari for example). Then, when I make one of my application's window active other 3-4 windows remain on the back.
Is there any way I can bring all the app's windows to front, when I make one of them active?
p.s. I know I can use [NSApp windows] and just call orderFrontRegardless in the loop, but I don't know how to catch the moment when one of my windows becomes active.
Any kind of help or a hint is really appreciated!
Upvotes: 0
Views: 1346
Reputation: 4107
This code does the trick for me:
-(void) applicationDidBecomeActive:(NSNotification *)notification
{
// TODO: go over windows here and bring them active
for (NSWindow * window in [NSApp orderedWindows]) {
[window orderFrontRegardless];
}
}
don't forget to set up the file to be the app's delegate in order for this code to work.
Upvotes: 2