2

I have a multi window Cocoa app, implemented using the techniques described in an answer to a previous question.

All works fine, however windows opened after the initial window come up and are shown front, but their state is not active (everything greyed). I have to explicitly click inside their frame to make them the active window.

My checks so far:

  • I've tried makeKeyAndOrderFront: but that doesn't make any difference.
  • The file owner in the NIB is set to the corresponding controller class of the window.
  • I can see in the Debugger that the instance of each controller is actually the owner of the corresponding window.
  • The solution suggested by NSThread does not make the the window key window.
  • The method canBecomeKeyWindow returns NO although the window is an instance of NSWindow.
  • The window has a title bar and is resizable.

What do I need to do to show subsequent windows in an active state?

EDIT:

I subclassed NSWindow with SecondaryWindow and override canBecomeKeyWindow to return YES. I changed to XIB to use the newly created subclass of NSWindow. Stepped through the code with the debugger, but still the window does not become the key window.

Community
  • 1
  • 1
Roger
  • 4,737
  • 4
  • 43
  • 68
  • 1
    Does `canBecomeKeyWindow` return YES? – paulmelnikow Oct 12 '11 at 05:11
  • Hmm.. no, it returns NO. I double checked the XIB file and the window is an instance of NSWindow according to IB which should return YES by default implementation according to the docs... – Roger Oct 13 '11 at 00:04

1 Answers1

0

Try this

[previousWindow orderBack];
[previousWindow resignKeyWindow];
[newWindow orderFront];
[newWindow makeKeyWindow];
  • An window can become key window if it have title bar or a resize bar.

If your application window don't have title bar or resize window then it can't become key window.

Parag Bafna
  • 22,812
  • 8
  • 71
  • 144
  • No, that doesn't do it either... New window has title bar and resize bar, so no show stopper there. – Roger Oct 12 '11 at 23:49