NSBorderlessWindowMask and key events

When a window is created with NSBorderlessWindowMask, it doesn't receive key events anymore.How to solve that ?

You have to create you own subclass ofNSWindowand implements the following methods:- (BOOL) canBecomeKeyWindow{ return YES;}

- (void)keyDown:(NSEvent *)theEvent{ // your code here}

- (void)keyUp:(NSEvent *)theEvent{ // your code here}and of course don't forget to change your initialization code to use the new window class or to change the class of the window in your nibs.

Authored by: peternlewis on Tuesday, July 22 2008 @ 06:06 AM BSTAnother thing that caught me out with NSBorderlessWindowMask is that if you are a LSUIElement background only application, and you have a Carbon run loop, then if you override initWithContentRect to specify a styleMask of NSBorderlessWindowMask, it kills the other styleMask flags as well, importantly including the Non Activating flag, which means the window does not start as the key window even if you makeKeyAndOrderFront.So instead of using styleMask: NSBorderlessWindowMask, use styleMask:styleMask&~NSTitledWindowMask (after making sure your nib has Non Activating turned on, and Close, Minimize and Zoom turned off).Also, remember to use [NSApp activateIgnoringOtherApps:YES]; otherwise again, the window will not become the key window.Two days of pain were required to figure out this Carbon/Cocoa interaction issue. I really hope this helps someone else!-----Keyboard Maestro Macros for your Mac