Applied patch [ 649590 ] fixes bug 611264: wxFileDialog entry
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
This commit is contained in:
@@ -1005,6 +1005,7 @@ BEGIN_EVENT_TABLE(wxFileDialog,wxDialog)
|
||||
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()
|
||||
|
||||
@@ -1285,6 +1286,27 @@ void wxFileDialog::OnTextEnter( wxCommandEvent &WXUNUSED(event) )
|
||||
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 );
|
||||
@@ -1297,7 +1319,9 @@ void wxFileDialog::OnSelected( wxListEvent &event )
|
||||
dir += filename;
|
||||
if (wxDirExists(dir)) return;
|
||||
|
||||
ignoreChanges = TRUE;
|
||||
m_text->SetValue( filename );
|
||||
ignoreChanges = FALSE;
|
||||
}
|
||||
|
||||
void wxFileDialog::HandleAction( const wxString &fn )
|
||||
|
Reference in New Issue
Block a user