From: Kevin Ollivier Date: Thu, 5 Mar 2009 21:21:45 +0000 (+0000) Subject: Sheet support for wxDirDialog. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a905992cf7eb7a5734133fc95944b98dde9c00d5 Sheet support for wxDirDialog. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59354 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/osx/dirdlg.h b/include/wx/osx/dirdlg.h index 8e7761505d..4ffad16d34 100644 --- a/include/wx/osx/dirdlg.h +++ b/include/wx/osx/dirdlg.h @@ -26,7 +26,6 @@ public: virtual int ShowModal(); protected: - wxWindow * m_parent; DECLARE_DYNAMIC_CLASS(wxDirDialog) }; diff --git a/src/osx/cocoa/dirdlg.mm b/src/osx/cocoa/dirdlg.mm index 6094f86e03..4f5063ba61 100644 --- a/src/osx/cocoa/dirdlg.mm +++ b/src/osx/cocoa/dirdlg.mm @@ -66,8 +66,36 @@ int wxDirDialog::ShowModal() wxCFStringRef dir( m_path ); m_path = wxEmptyString; + + wxNonOwnedWindow* parentWindow = NULL; + int returnCode = -1; + + if (GetParent()) + { + parentWindow = dynamic_cast(wxGetTopLevelParent(GetParent())); + } + else + { + fprintf(stderr, "No parent!\n"); + } - if ( [oPanel runModalForDirectory:dir.AsNSString() file:nil types:nil] == NSOKButton ) + if (parentWindow) + { + NSWindow* nativeParent = parentWindow->GetWXWindow(); + ModalDialogDelegate* sheetDelegate = [[ModalDialogDelegate alloc] init]; + [oPanel beginSheetForDirectory:dir.AsNSString() file:nil types: nil + modalForWindow: nativeParent modalDelegate: sheetDelegate + didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) + contextInfo: nil]; + [sheetDelegate waitForSheetToFinish]; + returnCode = [sheetDelegate code]; + [sheetDelegate release]; + } + else + { + returnCode = (NSInteger)[oPanel runModalForDirectory:dir.AsNSString() file:nil types:nil]; + } + if (returnCode == NSOKButton ) { wxCFStringRef resultpath( [[[oPanel filenames] objectAtIndex:0] retain] );