Change event names to clarify that they are only fired by button clicks, and note ways of retrieving search queries in the docs.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43939 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kevin Ollivier
2006-12-11 20:32:16 +00:00
parent 6235857802
commit c60122bf37
7 changed files with 27 additions and 25 deletions

View File

@@ -7,7 +7,7 @@ control, and a cancel button.
\wxheading{Derived from}
\helpref{wxTextCtrl}{wxsearchctrl}\\
\helpref{wxTextCtrl}{wxtextctrl}\\
streambuf\\
\helpref{wxControl}{wxcontrol}\\
\helpref{wxWindow}{wxwindow}\\
@@ -44,13 +44,14 @@ See also \helpref{window styles overview}{windowstyles} and \helpref{wxSearchCtr
\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}%

View File

@@ -37,8 +37,8 @@
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()
// ----------------------------------------------------------------------------
@@ -78,11 +78,11 @@ public:
// 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

View File

@@ -35,8 +35,8 @@
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

View File

@@ -137,7 +137,7 @@ protected:
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();
@@ -230,8 +230,10 @@ bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id,
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() );

View File

@@ -341,7 +341,7 @@ bool wxSearchCtrl::IsCancelButtonVisible() const
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 ;
@@ -349,7 +349,7 @@ wxInt32 wxSearchCtrl::MacSearchFieldSearchHit(WXEVENTHANDLERREF WXUNUSED(handler
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 ;

View File

@@ -39,8 +39,8 @@ class TestPanel(wx.Panel):
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)

View File

@@ -158,7 +158,6 @@ v10.3", "");
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.", "");
@@ -200,12 +199,12 @@ work on the Mac.", "");
%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)
}
//---------------------------------------------------------------------------