From e5eff438331d2b56b2770e1e369b03e843426a7f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 30 Sep 2012 20:35:10 +0000 Subject: [PATCH] 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 --- include/wx/generic/srchctlg.h | 2 +- src/generic/srchctlg.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/wx/generic/srchctlg.h b/include/wx/generic/srchctlg.h index 0d1fc5b539..7ccc89881e 100644 --- a/include/wx/generic/srchctlg.h +++ b/include/wx/generic/srchctlg.h @@ -219,7 +219,7 @@ protected: virtual wxBitmap RenderSearchBitmap( int x, int y, bool renderDrop ); virtual wxBitmap RenderCancelBitmap( int x, int y ); - virtual void OnSearchButton( wxCommandEvent& event ); + void OnCancelButton( wxCommandEvent& event ); void OnSetFocus( wxFocusEvent& event ); void OnSize( wxSizeEvent& event ); diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index 2317d2bfb5..8e472f4888 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -231,7 +231,7 @@ BEGIN_EVENT_TABLE(wxSearchButton, wxControl) END_EVENT_TABLE() 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_SIZE(wxSearchCtrl::OnSize) 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*/ ) -- 2.45.2