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...
OK, the solution is calling [NSApp activateIgnoringOtherApps:YES]; before opening alert. doh.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With