NSWindow / NSPanel 无法在全屏应用程序前显示



在我的应用程序中,有一个实用程序窗口(实际上它是一个NSPanel对象)。它会在某个时候出现并出现在其他应用程序的窗口前面。

但是,当其他应用程序以全屏模式运行时,不会显示实用程序窗口。但我发现当全屏应用程序运行时,它会创建新的桌面。

(我想这里的桌面是人们在其他问题中谈论的空间。

当我在Launchpad中检查"Mission Control"时,我看到实用程序窗口显示在原始桌面中,而全屏应用程序位于用户当前看到的新桌面中。

我阅读了文档并发现了一些类似的问题。似乎我应该设置窗口的集合行为。所以我试了这个:

[self.window setCollectionBehavior:NSWindowCollectionBehaviorDefault | NSWindowCollectionBehaviorTransient | NSWindowCollectionBehaviorFullScreenAuxiliary];

它不起作用。

如何将窗口移动到全屏应用程序创建的当前桌面/空间?

以下是我的测试代码,它工作正常,希望可以提供帮助。

NSPanel *test_panel = [[NSPanel alloc] initWithContentRect:NSMakeRect(300, 300, 500, 500) styleMask:NSTitledWindowMask|NSClosableWindowMask backing:NSBackingStoreBuffered defer:YES];
        [test_panel setReleasedWhenClosed:YES];
        [test_panel setHidesOnDeactivate:NO];
        [test_panel setFloatingPanel:YES];
        [test_panel setStyleMask:NSClosableWindowMask|NSTitledWindowMask | NSNonactivatingPanelMask];
        [test_panel setLevel:kCGMainMenuWindowLevel-1];
        [test_panel setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorFullScreenAuxiliary];
        [test_panel setCanBeVisibleOnAllSpaces:YES];
        [test_panel center];
        [test_panel orderFront:nil];

相关内容

最新更新