\wxheading{Derived from}
-\helpref{wxTextCtrl}{wxsearchctrl}\\
+\helpref{wxTextCtrl}{wxtextctrl}\\
streambuf\\
\helpref{wxControl}{wxcontrol}\\
\helpref{wxWindow}{wxwindow}\\
\wxheading{Event handling}
To process input from a search control, use these event handler macros to direct input to member
-functions that take a \helpref{wxCommandEvent}{wxcommandevent} argument.
+functions that take a \helpref{wxCommandEvent}{wxcommandevent} argument. To retrieve actual search
+queries, use EVT\_TEXT and EVT\_TEXT\_ENTER events, just as you would with \helpref{wxTextCtrl}{wxtextctrl}.
\twocolwidtha{9cm}%
\begin{twocollist}\itemsep=0pt
-\twocolitem{{\bf EVT\_SEARCHCTRL\_SEARCH(id, func)}}{Respond to a wxEVT\_SEARCHCTRL\_SEARCH event,
-generated when the search button is clicked.}
-\twocolitem{{\bf EVT\_SEARCHCTRL\_CANCEL(id, func)}}{Respond to a wxEVT\_SEARCHCTRL\_CANCEL event,
+\twocolitem{{\bf EVT\_SEARCHCTRL\_SEARCH\_BTN(id, func)}}{Respond to a wxEVT\_SEARCHCTRL\_SEARCH\_BTN event,
+generated when the search button is clicked. Note that this does not initiate a search.}
+\twocolitem{{\bf EVT\_SEARCHCTRL\_CANCEL\_BTN(id, func)}}{Respond to a wxEVT\_SEARCHCTRL\_CANCEL\_BTN event,
generated when the cancel button is clicked.}
\end{twocollist}%
extern WXDLLEXPORT_DATA(const wxChar) wxSearchCtrlNameStr[];
BEGIN_DECLARE_EVENT_TYPES()
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_CANCEL, 1119)
- DECLARE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_SEARCH, 1120)
+ DECLARE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, 1119)
+ DECLARE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, 1120)
END_DECLARE_EVENT_TYPES()
// ----------------------------------------------------------------------------
// macros for handling search events
// ----------------------------------------------------------------------------
-#define EVT_SEARCHCTRL_CANCEL(id, fn) \
- wx__DECLARE_EVT1(wxEVT_COMMAND_SEARCHCTRL_CANCEL, id, wxCommandEventHandler(fn))
+#define EVT_SEARCHCTRL_CANCEL_BTN(id, fn) \
+ wx__DECLARE_EVT1(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, id, wxCommandEventHandler(fn))
-#define EVT_SEARCHCTRL_SEARCH(id, fn) \
- wx__DECLARE_EVT1(wxEVT_COMMAND_SEARCHCTRL_SEARCH, id, wxCommandEventHandler(fn))
+#define EVT_SEARCHCTRL_SEARCH_BTN(id, fn) \
+ wx__DECLARE_EVT1(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, id, wxCommandEventHandler(fn))
#endif // wxUSE_SEARCHCTRL
const wxChar wxSearchCtrlNameStr[] = wxT("searchCtrl");
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_CANCEL)
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_SEARCH)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN)
#endif // wxUSE_SEARCHCTRL
m_search->SetFocus();
- if ( m_eventType == wxEVT_COMMAND_SEARCHCTRL_SEARCH )
+ if ( m_eventType == wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN )
{
// this happens automatically, just like on Mac OS X
m_search->PopupSearchMenu();
m_text = new wxSearchTextCtrl(this, value, style & ~wxBORDER_MASK);
- m_searchButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_SEARCH,m_searchBitmap);
- m_cancelButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_CANCEL,m_cancelBitmap);
+ wxSize sizeText = m_text->GetBestSize();
+
+ m_searchButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN,m_searchBitmap);
+ m_cancelButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN,m_cancelBitmap);
SetForegroundColour( m_text->GetForegroundColour() );
m_searchButton->SetForegroundColour( m_text->GetForegroundColour() );
wxInt32 wxSearchCtrl::MacSearchFieldSearchHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
{
- wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_SEARCH, m_windowId );
+ wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, m_windowId );
event.SetEventObject(this);
ProcessCommand(event);
return eventNotHandledErr ;
wxInt32 wxSearchCtrl::MacSearchFieldCancelHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
{
- wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_CANCEL, m_windowId );
+ wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, m_windowId );
event.SetEventObject(this);
ProcessCommand(event);
return eventNotHandledErr ;
self.Bind(wx.EVT_CHECKBOX, self.OnToggleCancelButton, cancelBtnOpt)
self.Bind(wx.EVT_CHECKBOX, self.OnToggleSearchMenu, menuBtnOpt)
- self.Bind(wx.EVT_SEARCHCTRL_SEARCH, self.OnSearch, self.search)
- self.Bind(wx.EVT_SEARCHCTRL_CANCEL, self.OnCancel, self.search)
+ self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.OnSearch, self.search)
+ self.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self.OnCancel, self.search)
self.search.Bind(wx.EVT_TEXT_ENTER, self.OnDoSearch) #, self.search)
attached, the search button will be visible regardless of the search
button visibility value. This always returns false in Mac OS X v10.3", "");
-
DocDeclStr(
virtual void , ShowCancelButton( bool show ),
"Shows or hides the cancel button.", "");
-%constant wxEventType wxEVT_COMMAND_SEARCHCTRL_CANCEL;
-%constant wxEventType wxEVT_COMMAND_SEARCHCTRL_SEARCH;
+%constant wxEventType wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN;
+%constant wxEventType wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN;
%pythoncode {
- EVT_SEARCHCTRL_CANCEL = wx.PyEventBinder( wxEVT_COMMAND_SEARCHCTRL_CANCEL, 1)
- EVT_SEARCHCTRL_SEARCH = wx.PyEventBinder( wxEVT_COMMAND_SEARCHCTRL_SEARCH, 1)
+ EVT_SEARCHCTRL_CANCEL_BTN = wx.PyEventBinder( wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, 1)
+ EVT_SEARCHCTRL_SEARCH_BTN = wx.PyEventBinder( wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, 1)
}
//---------------------------------------------------------------------------