Making child windows move with their parents
Making child windows move with their parents
- Subject: Making child windows move with their parents
- From: "Sumner Trammell" <email@hidden>
- Date: Thu, 31 Jul 2008 00:51:12 -0400
Hi. In my WebKit-based app, there is an occasional popup window, and
I'm trying to make it so that when you move the main window around,
the popup moves as well.
Here is my typical, vanilla WebView delegate method. In it, new
windows are made visible:
- (void)webViewShow:(WebView *)aSender {
NSDocumentController *theDocumentController =
[NSDocumentController sharedDocumentController];
MyDocument *theDocument = [theDocumentController
documentForWindow:[aSender window]];
[theDocument showWindows];
}
I tried adding this just before the [theDocument showWindows] call:
- (void)addChildWindow:(NSWindow *)childWindow
ordered:(NSWindowOrderingMode)orderingMode
like so:
- (void)webViewShow:(WebView *)aSender {
NSDocumentController *theDocumentController =
[NSDocumentController sharedDocumentController];
MyDocument *theDocument = [theDocumentController
documentForWindow:[aSender window]];
[[self window] addChildWindow:[aSender window] ordered:NSWindowAbove];
[theDocument showWindows];
}
but it doesn't work. I get *** -[MyDocument window]: unrecognized
selector sent to instance 0x1613ab30 in the run log.
aSender is the WebView in the main window.
self is the MyDocument object, and it has a window outlet that I can
see when I right-click the File's Owner in IB.
It seems to me that I want the new window to be made a child of the
current window. I obviously have something wrong, but I can't figure
out what.
I also tried:
[[[self webView] window] addChildWindow:[aSender window]
ordered:NSWindowAbove];
but that just crashes.
Thanks,
-s
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden