非模态对话框必须显示为模态窗口

时间:2013-06-27 10:39:42

标签: objective-c macos nswindow nswindowcontroller

我可以通过代码显示我的自定义NSWindowController作为模态窗口:

TSAppDelegate* appDelegate = (TSAppDelegate*) [[NSApplication sharedApplication] delegate];
NSWindow* mainWindow = appDelegate.window; 

[NSApp beginSheet: [self window]
   modalForWindow: mainWindow
    modalDelegate: NULL
   didEndSelector: NULL
      contextInfo: NULL];
int acceptedModal = (int)[NSApp runModalForWindow: [self window]];
[NSApp endSheet: [self window]];
[[self window] close];

有效。但我需要非模态窗口。它必须显示为模态(见图)并且是非模态的。

enter image description here

我试过

TSAppDelegate* appDelegate = (TSAppDelegate*) [[NSApplication sharedApplication] delegate];
NSWindow* mainWindow = appDelegate.window; 

[[self window] setParentWindow: mainWindow];

[mainWindow addChildWindow: [self window] ordered: NSWindowAbove];

它作为非模态工作,但显示为普通的弹出窗口。

有可能吗?

1 个答案:

答案 0 :(得分:3)

您似乎只想让一个窗口落在您的视图上,但不是模态的。

您可以使用单独的视图来动画进入和离开位置,而不是使用工作表。

您必须自己做一些工作:设置正确的位置,动画视图,响应事件等。

相关问题