0

I currently have a window open which was opened via:

// FirstWindowController
[self showWindow:self];
[[self window] makeKeyAndOrderFront:self];
[NSApp runModalForWindow:[self window]];

And upon click of a button I'd like to hide FirstWindowController via:

// FirstWindowController
[self.window orderOut:self];

And then show my second window:

// SecondWindowController
[self showWindow:self];
[[self window] makeKeyAndOrderFront:self];
[NSApp runModalForWindow:[self window]];

The first window disappears correctly, and the second window appears. But I can't actually use the NSTextFields in the input. But I can click the cancel button to hide SecondWindowController and give focus back to FirstWindowController.

Why can't I click any of the NSTextField elements?

Geesu
  • 5,928
  • 11
  • 43
  • 72

1 Answers1

1

I had the same problem. It worked when the window had a title bar and otherwise not. It seems like that a window needs to have a title to become a keyWindow.

The workaround for this is to make a subclass of NSWindow and override -canBecomeKeyWindow:

  • (BOOL)canBecomeKeyWindow { return YES; }