From daa3165144c0a10a1303ec9215e4c36d89cf35a4 Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Wed, 20 Apr 2011 14:54:56 +0000 Subject: [PATCH] Make use of SetFilterIndex in wxOSX-Cocoa's file dialog. Previously the file type would solely be based on the extension of the passed filename. This is still done, but any valid filter index as set by the user will now take precedence. See also #12429. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67551 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/cocoa/filedlg.mm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/osx/cocoa/filedlg.mm b/src/osx/cocoa/filedlg.mm index 77da694258..1aa5828bda 100644 --- a/src/osx/cocoa/filedlg.mm +++ b/src/osx/cocoa/filedlg.mm @@ -163,6 +163,7 @@ wxFileDialog::wxFileDialog( long style, const wxPoint& pos, const wxSize& sz, const wxString& name) : wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name) { + m_filterIndex = -1; } bool wxFileDialog::SupportsExtraControl() const @@ -467,8 +468,6 @@ int wxFileDialog::ShowModal() m_path = wxEmptyString; m_fileNames.Clear(); m_paths.Clear(); - // since we don't support retrieving the matching filter - m_filterIndex = -1; wxNonOwnedWindow* parentWindow = NULL; int returnCode = -1; @@ -490,8 +489,13 @@ int wxFileDialog::ShowModal() } m_firstFileTypeFilter = -1; - - if ( m_useFileTypeFilter ) + + if ( m_useFileTypeFilter + && m_filterIndex >= 0 && m_filterIndex < m_filterExtensions.GetCount() ) + { + m_firstFileTypeFilter = m_filterIndex; + } + else if ( m_useFileTypeFilter ) { types = nil; bool useDefault = true; -- 2.45.2