m_list->SetWild( *str );
}
-void wxFileDialog::OnActivated( wxListEvent &WXUNUSED(event) )
+void wxFileDialog::OnActivated( wxListEvent &event )
{
- wxCommandEvent cevent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
- cevent.SetEventObject( this );
- GetEventHandler()->ProcessEvent( cevent );
+ HandleAction( event.m_item.m_text );
}
void wxFileDialog::OnTextEnter( wxCommandEvent &WXUNUSED(event) )
void wxFileDialog::OnSelected( wxListEvent &event )
{
- if (FindFocus() == m_list)
- m_text->SetValue( event.m_item.m_text );
+ if (FindFocus() != m_list) return;
+
+ wxString filename( event.m_item.m_text );
+ if (filename == _T("..")) return;
+
+ wxString dir;
+ m_list->GetDir( dir );
+ if (dir != _T("/")) dir += _T("/");
+ dir += filename;
+ if (wxDirExists(dir)) return;
+
+ m_text->SetValue( filename );
}
-void wxFileDialog::OnListOk( wxCommandEvent &event )
+void wxFileDialog::HandleAction( const wxString &fn )
{
- wxString filename( m_text->GetValue() );
+ wxString filename( fn );
wxString dir;
m_list->GetDir( dir );
if (filename.IsEmpty()) return;
if (wxDirExists(filename))
{
m_list->GoToDir( filename );
- if (filename == _T("/"))
- m_text->SetValue( _T("") );
- else
- m_text->SetValue( _T("..") );
m_list->GetDir( dir );
m_static->SetLabel( dir );
return;
}
SetPath( filename );
- event.Skip();
+
+ wxCommandEvent event;
+ wxDialog::OnOK(event);
+}
+
+void wxFileDialog::OnListOk( wxCommandEvent &WXUNUSED(event) )
+{
+ HandleAction( m_text->GetValue() );
}
void wxFileDialog::OnList( wxCommandEvent &WXUNUSED(event) )
wxFileSelectorEx(const wxChar *message,
const wxChar *default_path,
const wxChar *default_filename,
- int *indexDefaultExtension,
+ int *WXUNUSED(indexDefaultExtension),
const wxChar *wildcard,
int flags,
wxWindow *parent,