Make Cocoa app on top of fullscreen apps

I am working on an application that has a status menu, and from this menu the user can open the main application window. I need to open this window on top of full-screen applications. The following code works fine if the Application is an agent (UIElement) installed YES :

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

However, I want to have an icon in the dock. If the Application is an agent (UIElement) is set to NO , showMainWindow forces the application to move to another space, rather than appearing on top of the active full-screen application. Is there a solution for this?

+4
source share
1 answer

I answer my question here for the sake of completeness.

Once a small study is found out, there is no way around it. This is just an OS X way.

My solution: I gave the user an option in the application settings whether they want the application to be an application such as a docking station or an agent type. Set Application is agent (UIElement) to YES in the main plist. You can change the type of application at runtime by setting the application activation policy to NSApplicationActivationPolicyRegular.

+3
source

Source: https://habr.com/ru/post/1387301/


All Articles