Question

I have a status bar menu app - it doesn't run in the Dock (UIElement is YES).

After a user-defined period, it brings one of its window to the front (using makeKeyAndOrderFront). An NSTimer is set up to get rid of it after a few seconds - I close the window and hide the app with: [NSApp hide];

My question is, how can I bring the previous app's window back to the front? It's visible but not the front/focus window.

EDIT: If it helps to clarify what I'm trying to do, when you invoke the application Dash with the keyboard shortcut and then dismiss it, the app that was previously front, returns to the front.

Was it helpful?

Solution

I was overthinking - as a user, it's possible to hide an app, which automatically restores focus to the window in the app next in line. That's all I had to do in code:

[NSApp hide:nil];

To play nicely with full-screen apps, I also have to close the window in my app, even though it's been hidden - otherwise, when my app's window is next shown, OS X jumps to the Space where my window was last seen, a jarring experience.

[self.theWindow close];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top