I need to launch my application without windows, but when an error occurs I need to display the error in a window. My problem is that I can’t make my window as first responder, so the windows buttons aren’t working because the window is not in focus.
I created a window and its controller. The button have the action defined.
Any ideas?
This is my source code:
@interface ErrorWindow : NSWindowController {
IBOutlet NSImageView *_imageView;
IBOutlet NSTextField *_message_text;
IBOutlet NSTextField *_informative_text;
IBOutlet NSWindow *_errorWindow;
}
- (IBAction)closeWindowAction:(id)sender;
In my implementation:
- (void)awakeFromNib {
[_errorWindow makeKeyAndOrderFront:self];
[NSApp activateIgnoringOtherApps:YES];
}
Maybe the problem is that you are calling
[NSApp activateIgnoringOtherApps:YES];after displaying the window. Have you tried reversing the order?