本文介绍了保持NSWindow前面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从我的主要NSWindow开启一个NSWindow。

I open a NSWindow from my main NSWindow.

DropHereWindowController *dropHereWindowController = [[DropHereWindowController alloc] initWithWindowNibName:@"DropHereWindow"];
[dropHereWindowController showWindow:nil];

我想把这个窗口停留在主窗口的顶部, DropHereWindow。然而,当打开finder(不再有焦点)我的DropHereWindow在我的主窗口后面。

I want this window to stay on top of my main window when dragging a file from the finder to that "DropHereWindow". However when opening the finder (not having the focus any longer) my "DropHereWindow" goes behind my main window.

我试过orderFront,makeKey,makeKeyAndFront但没有帮助。
我能做些什么呢?

I tried orderFront, makeKey, makeKeyAndFront but nothing helped.What can I do about it?

推荐答案

方法:

- (void)setLevel:(NSInteger)windowLevel

子类NSWindow:

Sub-class the NSWindow:

[self setLevel: NSStatusWindowLevel];

或直接使用:

[window setLevel: NSStatusWindowLevel];

可用级别:


  • NSNormalWindowLevel

  • NSFloatingWindowLevel

  • NSSubmenuWindowLevel

  • NSTornOffMenuWindowLevel

  • NSModalPanelWindowLevel

  • NSMainMenuWindowLevel

  • NSStatusWindowLevel

  • NSPopUpMenuWindowLevel

  • NSScreenSaverWindowLevel

  • kCGDesktopWindowLevel

  • NSNormalWindowLevel
  • NSFloatingWindowLevel
  • NSSubmenuWindowLevel
  • NSTornOffMenuWindowLevel
  • NSModalPanelWindowLevel
  • NSMainMenuWindowLevel
  • NSStatusWindowLevel
  • NSPopUpMenuWindowLevel
  • NSScreenSaverWindowLevel
  • kCGDesktopWindowLevel

这篇关于保持NSWindow前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 00:27