Nikolozi
Nikolozi

Reputation: 2242

Make Cocoa app stay on top of fullscreen apps

I'm working on an app that has a status menu and from that menu user can open the app's main window. I want the ability to open this window on top of the full screen apps. The following code works fine if Application is agent (UIElement) is set to YES:

- (IBAction)showMainWindow:(id)sender
{
   [_window makeKeyAndOrderFront:self];
   [NSApp activateIgnoringOtherApps:YES];
}

However, I want to have an icon in the dock as well. If Application is agent (UIElement) is set to NO showMainWindow causes the app to jump to a different space rather than appearing on top of the active full screen app. Is there a solution to this?

Upvotes: 4

Views: 941

Answers (1)

Nikolozi
Nikolozi

Reputation: 2242

I'm answering my own question here for the sake of completeness.

After little more research turns out there is no way around it. It just the way OS X works.

My solution: I gave user an option in app preferences whether they want the app to be a dock type app or the agent type. Set the Application is agent (UIElement) to YES in main plist. You can change the app type during runtime by setting the app activation policy to NSApplicationActivationPolicyRegular.

Upvotes: 3

Related Questions