Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alert window in 'application as agent' not given focus

UPDATE: My application is runing as agent, I found when I turn that off, the alert window is given focus normally. Any ideas how to solve that?

I am showing an alert window first time the application is ran in AppController's awakeFromNib. When I run it in Xcode, it's runs as a key window, but when I build the app, it's not given focus. Why? How can I give it focus?

AppController.m

NSInteger kbSetup = NSRunAlertPanel(kbLetsStart, kbLetsStartDscr, @"OK", @"Maybe Later", nil);
kbSetup == 1 ? [self showPreferencesPanel:nil] : [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0];

Even if I create an instance of NSAlert, and then do [[alert window] makeKeyAndOrderFront:self] , it's still not key...

like image 542
janeh Avatar asked Mar 26 '26 18:03

janeh


1 Answers

OK, the solution is calling [NSApp activateIgnoringOtherApps:YES]; before opening alert. doh.

like image 146
janeh Avatar answered Mar 28 '26 13:03

janeh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!