diff --git a/include/wx/osx/dirdlg.h b/include/wx/osx/dirdlg.h index a77cd0f880..cf22b6ad4d 100644 --- a/include/wx/osx/dirdlg.h +++ b/include/wx/osx/dirdlg.h @@ -47,6 +47,10 @@ public: virtual int ShowModal() wxOVERRIDE; + virtual wxString GetPath() const wxOVERRIDE; + virtual void GetPaths(wxArrayString& paths) const wxOVERRIDE; + + #if wxOSX_USE_COCOA virtual void ShowWindowModal() wxOVERRIDE; virtual void ModalFinishedCallback(void* panel, int returnCode) wxOVERRIDE; @@ -64,6 +68,8 @@ private: // Common part of all ctors. void Init(); + wxArrayString m_paths; + wxDECLARE_DYNAMIC_CLASS(wxDirDialog); }; diff --git a/src/osx/cocoa/dirdlg.mm b/src/osx/cocoa/dirdlg.mm index e3f86108e9..93bb4ad6bb 100644 --- a/src/osx/cocoa/dirdlg.mm +++ b/src/osx/cocoa/dirdlg.mm @@ -48,6 +48,9 @@ void wxDirDialog::Create(wxWindow *parent, const wxString& message, { m_parent = parent; + wxASSERT_MSG( !( (style & wxDD_MULTIPLE) && (style & wxDD_CHANGE_DIR) ), + "wxDD_CHANGE_DIR can't be used together with wxDD_MULTIPLE" ); + SetMessage( message ); SetWindowStyle(style); SetPath(defaultPath); @@ -73,6 +76,9 @@ WX_NSOpenPanel wxDirDialog::OSXCreatePanel() const if ( !HasFlag(wxDD_DIR_MUST_EXIST) ) [oPanel setCanCreateDirectories:YES]; + if ( HasFlag(wxDD_MULTIPLE) ) + [oPanel setAllowsMultipleSelection:YES]; + if ( HasFlag(wxDD_SHOW_HIDDEN) ) [oPanel setShowsHiddenFiles:YES]; @@ -142,8 +148,7 @@ void wxDirDialog::ModalFinishedCallback(void* panel, int returnCode) for ( NSURL* url in selectedURL ) { - SetPath([url fileSystemRepresentation]); - break; + m_paths.Add([url fileSystemRepresentation]); } result = wxID_OK; @@ -154,5 +159,16 @@ void wxDirDialog::ModalFinishedCallback(void* panel, int returnCode) SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED ); } +wxString wxDirDialog::GetPath() const +{ + return m_paths.Last(); +} + +void wxDirDialog::GetPaths(wxArrayString& paths) const +{ + paths.Empty(); + paths = m_paths; +} + #endif // wxUSE_DIRDLG