I am trying to open one window from another using makeKeyAndOrderFront. The new window appears, but does not receive focus.
The code for the main window is:
#import "SecondWindowController.h"
@implementation FirstWindowController
-(IBAction)showSecondWindow:(id)sender
{
if (!secondWindowController)
secondWindowController = [[SecondWindowController alloc] init];
[[secondWindowController window] makeKeyAndOrderFront:self];
}
SecondWindowController is a NSWindowController, as follows:
@implementation SecondWindowController
-(id)init
{
if (![super initWithWindowNibName:@"SecondWindow"])
return nil;
return self;
}
I've also tried putting [secondWindowController showWindow:self]
before the makeKeyAndOrderFront
but it doesn't make a difference.