In bug 611264 I reported that typing a filename into a
multiple selection file dialog failed. The file
returned was "..".
I discovered that this was because the previous
directory folder came up automatically selected when
the dialog was created. Then, I discovered a related
bug. If any file or folder was selected, then that was
the file which was returned regardless of what was
typed in.
To fix the problem I added an EVT_TEXT handler which
deselects everything that is selected when the user
types. The handler does not deselect anything unless
the user actually types something.
This patch implements the fix.
John Skiff
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18144
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
void OnNew( wxCommandEvent &event );
void OnChoiceFilter( wxCommandEvent &event );
void OnTextEnter( wxCommandEvent &event );
void OnNew( wxCommandEvent &event );
void OnChoiceFilter( wxCommandEvent &event );
void OnTextEnter( wxCommandEvent &event );
+ void OnTextChange( wxCommandEvent &event );
void OnCheck( wxCommandEvent &event );
void HandleAction( const wxString &fn );
void OnCheck( wxCommandEvent &event );
void HandleAction( const wxString &fn );
EVT_LIST_ITEM_ACTIVATED(ID_LIST_CTRL, wxFileDialog::OnActivated)
EVT_CHOICE(ID_CHOICE,wxFileDialog::OnChoiceFilter)
EVT_TEXT_ENTER(ID_TEXT,wxFileDialog::OnTextEnter)
EVT_LIST_ITEM_ACTIVATED(ID_LIST_CTRL, wxFileDialog::OnActivated)
EVT_CHOICE(ID_CHOICE,wxFileDialog::OnChoiceFilter)
EVT_TEXT_ENTER(ID_TEXT,wxFileDialog::OnTextEnter)
+ EVT_TEXT(ID_TEXT,wxFileDialog::OnTextChange)
EVT_CHECKBOX(ID_CHECK,wxFileDialog::OnCheck)
END_EVENT_TABLE()
EVT_CHECKBOX(ID_CHECK,wxFileDialog::OnCheck)
END_EVENT_TABLE()
GetEventHandler()->ProcessEvent( cevent );
}
GetEventHandler()->ProcessEvent( cevent );
}
+static bool ignoreChanges = FALSE;
+
+void wxFileDialog::OnTextChange( wxCommandEvent &WXUNUSED(event) )
+{
+ if (!ignoreChanges)
+ {
+ // Clear selections. Otherwise when the user types in a value they may
+ // not get the file whose name they typed.
+ if (m_list->GetSelectedItemCount() > 0)
+ {
+ long item = m_list->GetNextItem(-1, wxLIST_NEXT_ALL,
+ wxLIST_STATE_SELECTED);
+ while ( item != -1 )
+ {
+ m_list->SetItemState(item,0, wxLIST_STATE_SELECTED);
+ item = m_list->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ }
+ }
+ }
+}
+
void wxFileDialog::OnSelected( wxListEvent &event )
{
wxString filename( event.m_item.m_text );
void wxFileDialog::OnSelected( wxListEvent &event )
{
wxString filename( event.m_item.m_text );
dir += filename;
if (wxDirExists(dir)) return;
dir += filename;
if (wxDirExists(dir)) return;
m_text->SetValue( filename );
m_text->SetValue( filename );
}
void wxFileDialog::HandleAction( const wxString &fn )
}
void wxFileDialog::HandleAction( const wxString &fn )