Fix setting the title for the wxDirDialog on OSX
OSX 10.11+ doesn't actually display the title, so update documentation to reference SetMessage instead. For pre-10.11 override the SetTitle method to set the title of the NSOpenPanel instead of the window. Also change so the directory is not updated unless it is provided. Closes #15143.
This commit is contained in:
committed by
Vadim Zeitlin
parent
61afcae0be
commit
7230acd110
@@ -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);
|
||||
};
|
||||
|
@@ -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}
|
||||
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user