我们的应用程序需要覆盖到全屏。使用常规全屏(浏览器Flash全屏像Prezi或Youtube)它可以工作,但使用原生全屏(Lion全屏,全屏模式,其他空间)它不会...
问题是,如何强制窗口,全屏模式和KeyNote全屏显示?
示例应用:
_window是NSWindow(NSPanel也不会工作)
- (void) activeSpaceDidChange:(NSNotification *)aNotification {
if ([_window isVisible] && ![_window isOnActiveSpace])
[_window orderOut:self];
[_window setCollectionBehavior: NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorFullScreenAuxiliary];
[_window makeKeyAndOrderFront:self];
[_window setCollectionBehavior:NSWindowCollectionBehaviorMoveToActiveSpace | NSWindowCollectionBehaviorFullScreenAuxiliary];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[_window setCollectionBehavior: NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorFullScreenAuxiliary];
[_window orderFrontRegardless];
[_window setLevel:NSStatusWindowLevel];
[_window setHidesOnDeactivate: NO];
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(activeSpaceDidChange:) name:NSWorkspaceActiveSpaceDidChangeNotification object:nil];
}
修改
现在使用Tyler的代码片段,面板可以使用FullScreen模式,但遗憾的是没有使用KeyNote全屏模式。
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[_window setStyleMask:NSUtilityWindowMask | NSNonactivatingPanelMask];
[_window setLevel:NSFloatingWindowLevel];
[_window setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorFullScreenAuxiliary];
}
答案 0 :(得分:3)
您不应该要求“activeSpaceDidChange”通知行,它似乎确实需要是NSPanel。在您的applicationDidFinishLaunching中,只需执行以下操作即可:
[_window setStyleMask:NSUtilityWindowMask | NSNonactivatingPanelMask];
[_window setLevel:NSFloatingWindowLevel];
[_window setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorFullScreenAuxiliary];