borderless child NSWindow not getting events
I create a NSWindow with this code, but I don't receive any mouse or keyboard events for it:
window = [[OverlayWindow alloc] initWithContentRect:bounds styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
[parentWindow addChildWindo开发者_开发知识库w:window ordered:NSWindowAbove];
NSView * rootView = [[OverlayView alloc] init];
[window setOpaque:NO];
[window setBackgroundColor:[NSColor clearColor]];
[window setContentView:rootView];
[window setIgnoresMouseEvents:NO];
[self reshapeToRect:bounds];
and in OverlayWindow:
- (BOOL) canBecomeKeyWindow { return YES; }
- (BOOL) canBecomeMainWindow { return YES; }
- (BOOL) acceptsFirstResponder { return YES; }
- (BOOL) becomeFirstResponder { return YES; }
- (BOOL) resignFirstResponder { return YES; }
[window orderWindow:NSWindowAbove relativeTo:[parentWindow windowNumber]];
did the trick
精彩评论