diff --git a/include/wx/osx/dirdlg.h b/include/wx/osx/dirdlg.h index cf22b6ad4d..ea95b70c5a 100644 --- a/include/wx/osx/dirdlg.h +++ b/include/wx/osx/dirdlg.h @@ -47,6 +47,10 @@ public: virtual int ShowModal() wxOVERRIDE; + // MacOS 10.11 has removed the titlebar from the dialog, so this is provided + // only for compatibility with older versions + virtual void SetTitle(const wxString& title) wxOVERRIDE; + virtual wxString GetPath() const wxOVERRIDE; virtual void GetPaths(wxArrayString& paths) const wxOVERRIDE; @@ -69,6 +73,7 @@ private: void Init(); wxArrayString m_paths; + wxString m_title; wxDECLARE_DYNAMIC_CLASS(wxDirDialog); }; diff --git a/interface/wx/dirdlg.h b/interface/wx/dirdlg.h index d4f6c6eaa6..c8f5b29728 100644 --- a/interface/wx/dirdlg.h +++ b/interface/wx/dirdlg.h @@ -71,6 +71,11 @@ const char wxDirDialogNameStr[] = "wxDirCtrl"; @endcode instead of just using @c wxDD_DIR_MUST_EXIST style alone. + @remarks MacOS 10.11+ does not display a title bar on the dialog. Use SetMessage() + to change the string displayed to the user at the top of the dialog after creation. + The SetTitle() method is provided for compatibility with pre-10.11 MacOS versions + that do still support displaying the title bar. + @library{wxcore} @category{cmndlg} diff --git a/src/osx/cocoa/dirdlg.mm b/src/osx/cocoa/dirdlg.mm index 93bb4ad6bb..9c21b7ea95 100644 --- a/src/osx/cocoa/dirdlg.mm +++ b/src/osx/cocoa/dirdlg.mm @@ -73,6 +73,12 @@ WX_NSOpenPanel wxDirDialog::OSXCreatePanel() const wxCFStringRef cf( m_message ); [oPanel setMessage:cf.AsNSString()]; + if ( !m_title.empty() ) + { + wxCFStringRef cfTitle(m_title); + [oPanel setTitle:cfTitle.AsNSString()]; + } + if ( !HasFlag(wxDD_DIR_MUST_EXIST) ) [oPanel setCanCreateDirectories:YES]; @@ -159,6 +165,12 @@ void wxDirDialog::ModalFinishedCallback(void* panel, int returnCode) SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED ); } +void wxDirDialog::SetTitle(const wxString &title) +{ + m_title = title; + wxDialog::SetTitle(title); +} + wxString wxDirDialog::GetPath() const { return m_paths.Last();