4

I can send the message makeKeyAndOrderFront: to make a window active. However, if I send this to a window without a title bar, it doesnt make it active. Is there any way to make a window without a title bar active?

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
hollow7
  • 1,506
  • 1
  • 12
  • 20
  • What do you mean by “doesnt make it active”? Also, did you add anything special to your Info.plist? – Peter Hosey Nov 26 '11 at 20:12
  • actually i suspect a window without a title bar cant be made active. cos the normal behavior of a window when clicked is to be active, that is the UI controls change color in an obvious way, but i cant ever make it active when i click on this titlebar-less window. Nope nothing special added to info.plist. – hollow7 Nov 26 '11 at 21:55
  • 1
    I'm pretty sure that's not the case, particularly since some custom-title-bar windows are done as borderless windows. I'd encourage you to keep poking the methods of NSWindow and NSPanel until you find the right combination of settings. – Peter Hosey Nov 27 '11 at 01:52

1 Answers1

4

You need to override -canBecomeKeyWindow in your NSWindow subclass to return YES.

As per the docs:

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.

Rob Keniger
  • 45,830
  • 6
  • 101
  • 134