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?

3
  • What do you mean by “doesnt make it active”? Also, did you add anything special to your Info.plist? Nov 26, 2011 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, 2011 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. Nov 27, 2011 at 1:52

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.