我使用此代码创建了一个NSWindow,但我没有收到任何鼠标或键盘事件:
window = [[OverlayWindow alloc] initWithContentRect:bounds styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
[parentWindow addChildWindow:window ordered:NSWindowAbove];
NSView * rootView = [[OverlayView alloc] init];
[window setOpaque:NO];
[window setBackgroundColor:[NSColor clearColor]];
[window setContentView:rootView];
[window setIgnoresMouseEvents:NO];
[self reshapeToRect:bounds];
并在OverlayWindow中:
- (BOOL) canBecomeKeyWindow { return YES; }
- (BOOL) canBecomeMainWindow { return YES; }
- (BOOL) acceptsFirstResponder { return YES; }
- (BOOL) becomeFirstResponder { return YES; }
- (BOOL) resignFirstResponder { return YES; }
答案 0 :(得分:3)
[window orderWindow:NSWindowAbove relativeTo:[parentWindow windowNumber]];
做了这个伎俩