I have a main window that is the center of my application. For different functions I open a child window to handle certain specialized functions. I want all of the windows to move independently, but right now if I 开发者_运维知识库move the original, central window then all of those child windows move with it. How can I make the child windows disconnected so they don't move with the parent?
Remove children temporarily before the window is moved, then put them back:
- (void)windowWillMove:(NSNotification *)notification;
{
[window removeChildWindow:child];
}
- (void)windowDidMove:(NSNotification *)notification
{
if (![window inLiveResize])
[window addChildWindow:child ordered:NSWindowAbove];
}
Or, if you don't need NSWindowAbove ordering, just don't make them child in the first place :)
Another way you can show your child window without adding it as a child window, but achieve the same behavior within window' level:
[self.childWindowController showWindow:self];
[self.childWindowController.window setLevel:NSSubmenuWindowLevel];
I'm not sure is this method is correct and good solution, but it works for me.
精彩评论