Cocoa 为什么可以';从菜单项调用的NSPopover的I控制窗口级别?

Cocoa 为什么可以';从菜单项调用的NSPopover的I控制窗口级别?,cocoa,nspopover,Cocoa,Nspopover,我是另一个试图使应用程序在popover中相对于系统状态栏菜单显示自己的人。 我试图避免使用自定义类,并使用基本nspover 它工作正常,除了它的窗口级别-我无法控制它,所以我的popover出现在所有东西上:通知中心和Spot Lite,任务控制不会影响它 这是我的示例代码(来自): 您能帮我理解一下我是否能修复它以及如何修复它吗?我的猜测是,当它显示时,它会将其级别设置为与其相对的视图窗口的级别。对于状态项按钮,它将是NSStatusWindowLevel。在显示标高设置后,尝试将其移动

我是另一个试图使应用程序在popover中相对于系统状态栏菜单显示自己的人。 我试图避免使用自定义类,并使用基本nspover

它工作正常,除了它的窗口级别-我无法控制它,所以我的popover出现在所有东西上:通知中心和Spot Lite,任务控制不会影响它

这是我的示例代码(来自):


您能帮我理解一下我是否能修复它以及如何修复它吗?

我的猜测是,当它显示时,它会将其级别设置为与其相对的视图窗口的级别。对于状态项按钮,它将是
NSStatusWindowLevel
。在显示标高设置后,尝试将其移动到。
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

// Adding menulet _POP_ to status bar
self.myItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
[self.myItem setAction:@selector(showPopover:)];
[self.myItem setTitle:@"_POP_"];
[self.myItem setHighlightMode:YES];
[self.myItem setTarget:self];
[self.myItem setEnabled:YES];
}

-(void) showPopover:(id)sender {

// Click POP to see Popover

NSViewController *controller = [[NSViewController alloc] initWithNibName:@"viewController" bundle:nil];
NSPopover *popover = [[NSPopover alloc] init];
[popover setContentViewController:controller];
[popover setAnimates:NO];
[popover.contentViewController.view.window setLevel:NSPopUpMenuWindowLevel];
                                                //    NSDockWindowLevel
                                                //    NSFloatingWindowLevel
                                                //    NSMainMenuWindowLevel
                                                //    NSNormalWindowLevel
                                                //    NSPopUpMenuWindowLevel
                                                //    NSScreenSaverWindowLevel
                                                //    NSStatusWindowLevel
                                                //    NSSubmenuWindowLevel
                                                //    NSTornOffMenuWindowLevel

// Showing the Popover
[popover showRelativeToRect:self.myItem.button.frame ofView:self.myItem.button preferredEdge:NSMaxYEdge];

// Run Mission Control while Popover is open to see the problem
// It neither moves as window nor disappears as panel

// If you can solve it, please mail to the.efojs@gmail.com

}