开发者

borderless child NSWindow not getting events

开发者 https://www.devze.com 2023-04-11 05:01 出处:网络
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:NSBac

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

精彩评论

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