I created the main window in my application to have the following settings:
[self setLevel:kCGDesktopWindowLevel + 1]; [self setCollectionBehavior: (NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorStationary | NSWindowCollectionBehaviorIgnoresCycle)];
This is a very customizable window, similar to floats above the desktop.
It is also a menu application ( LSUIElement ).
Ok, so I need to display a warning if something is wrong. Here is how I do it:
NSAlert *alert = [NSAlert alertWithMessageText:@"" defaultButton:@"" alternateButton:@"" otherButton:@"" informativeTextWithFormat:@""]; [alert runModal];
Of course, I typed buttons and other text.
Here is my problem: when my application is not currently a key application and this warning appears, it is not a key window. Like this:

See how the window is not selected? Is there any way around this without changing my app window level? Thanks!
objective-c cocoa macos
sudo rm -rf
source share