Loading NIB using [NSBundle loadNibNamed: owner:], but the window does not appear in the foreground

I wrote a menu application in which there is no permanent window or standard menu. When another application has focus, and I use the menulet to launch the window that needs to be opened, it appears behind the foreground application (but above everything else on the screen).

Primarily...

-(IBAction)aboutWindow:(id)sender {
    [NSBundle loadNibNamed:@"About" owner:self];
}

Can someone point me in the right direction so that I can open this window above all other applications when it is initially spawned?

[change]

I tried using a custom NSWindowController with a window connected and awakeFromNib calling the makekeyandorderfront method, but it did nothing.

Now I have instead of calling NSBundle:

NSWindowController* awc = [[NSWindowController alloc] initWithWindowNibName:@"About"];
[[awc window] makeKeyAndOrderFront:nil];

,

+3
2

. , . - menulet , . :

-(IBAction)aboutWindow:(id)sender {
    NSWindowController* awc = [[NSWindowController alloc] initWithWindowNibName:@"About"];
    [[awc window] makeKeyAndOrderFront:nil];
    [[NSApplication sharedApplication] arrangeInFront:nil];
}
+2

makeKeyAndOrderFront:

, About - , myWindow:

- (void)awakeFromNib 
{
    [myWindow makeKeyAndOrderFront:nil];
}
+1

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


All Articles