Clear the search control automatically when it's "Cancel" button is pressed.

This should be the desired behaviour in the vast majority of cases, so do it
by default.

Replace the useless OnSearchButton() doing nothing with search button events
with OnCancelButton() handling cancel button events and clearing the control.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72581 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-09-30 20:35:10 +00:00
parent 274e4265a8
commit e5eff43833
2 changed files with 4 additions and 4 deletions

View File

@@ -219,7 +219,7 @@ protected:
virtual wxBitmap RenderSearchBitmap( int x, int y, bool renderDrop ); virtual wxBitmap RenderSearchBitmap( int x, int y, bool renderDrop );
virtual wxBitmap RenderCancelBitmap( int x, int y ); virtual wxBitmap RenderCancelBitmap( int x, int y );
virtual void OnSearchButton( wxCommandEvent& event ); void OnCancelButton( wxCommandEvent& event );
void OnSetFocus( wxFocusEvent& event ); void OnSetFocus( wxFocusEvent& event );
void OnSize( wxSizeEvent& event ); void OnSize( wxSizeEvent& event );

View File

@@ -231,7 +231,7 @@ BEGIN_EVENT_TABLE(wxSearchButton, wxControl)
END_EVENT_TABLE() END_EVENT_TABLE()
BEGIN_EVENT_TABLE(wxSearchCtrl, wxSearchCtrlBase) BEGIN_EVENT_TABLE(wxSearchCtrl, wxSearchCtrlBase)
EVT_SEARCHCTRL_SEARCH_BTN(wxID_ANY, wxSearchCtrl::OnSearchButton) EVT_SEARCHCTRL_CANCEL_BTN(wxID_ANY, wxSearchCtrl::OnCancelButton)
EVT_SET_FOCUS(wxSearchCtrl::OnSetFocus) EVT_SET_FOCUS(wxSearchCtrl::OnSetFocus)
EVT_SIZE(wxSearchCtrl::OnSize) EVT_SIZE(wxSearchCtrl::OnSize)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -1172,9 +1172,9 @@ void wxSearchCtrl::RecalcBitmaps()
} }
} }
void wxSearchCtrl::OnSearchButton( wxCommandEvent& event ) void wxSearchCtrl::OnCancelButton( wxCommandEvent& WXUNUSED(event) )
{ {
event.Skip(); m_text->Clear();
} }
void wxSearchCtrl::OnSetFocus( wxFocusEvent& /*event*/ ) void wxSearchCtrl::OnSetFocus( wxFocusEvent& /*event*/ )