开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜