]> git.saurik.com Git - wxWidgets.git/commitdiff
Clear the search control automatically when it's "Cancel" button is pressed.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 30 Sep 2012 20:35:10 +0000 (20:35 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 30 Sep 2012 20:35:10 +0000 (20:35 +0000)
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
src/generic/srchctlg.cpp

index 0d1fc5b539282de3e884c6635ffc9c33cd14998b..7ccc89881edd11ccc56da1ff014738983425bc15 100644 (file)
@@ -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 );
index 2317d2bfb5be7f7fbf1e06f830a5fd9b162b8f38..8e472f4888174e0597bd434464850e4edd9d3147 100644 (file)
@@ -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*/ )