Search code examples
objective-ccocoawindowmakekeyandordertofront

How to make active a window without a title bar


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?


Solution

  • 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.