1

In my app I've got a secondary NSWindow that's created from .xib in my NSWindowController in my initWithWindowNibName: method. The window is a plain NSWindow with the title bar switched off.

After creating the window it's shown using makeKeyAndOrderFront: -
and all controls are disabled (text field, combo box).

I have (more than..) triple checked all flags in the window and the view hierarchy of the controls: everything is enabled, allowing editing and not refusing to be first responder.

Totally clueless. Any ideas?

Update #1:
I appears the problem is related to the window not having a title bar. When the title bar is switched on the window - and the controls in the window - behave as expected.

ATV
  • 4,116
  • 3
  • 23
  • 42
  • 2
    By "all flags", do you just mean the ones which can be set in IB? In particular, if your window doesn't have a title, then `-canBecomeMainWindow` and `-canBecomeKeyWindow` return `FALSE`. You probably need to override them to return `TRUE`. – Ken Thomases May 18 '14 at 18:29
  • @KenThomases Indeed - just the IB flags. Ok, I'll try with a subclass then. Cumbersome, though.. – ATV May 18 '14 at 18:30
  • You mean the only controls in the window are text fields and combo boxes? Such controls need to be in a key window and become first responder in order to function, whereas other controls like buttons can work without being in a key window. – JWWalker May 19 '14 at 00:43

1 Answers1

2

As pointed out by Ken the framework will automatically refuse becoming a key window if the window title is switched off:

Attempts to make the window the key window are abandoned if this method returns NO. The NSWindow implementation returns YES if the window has a title bar or a resize bar, or NO otherwise.

A simple subclass did the trick.

ATV
  • 4,116
  • 3
  • 23
  • 42