Log focus messages for the search control in the widgets sample

This makes it easier to test various issues related to focus events for
composite controls, such as wxSearchCtrl.
This commit is contained in:
Vadim Zeitlin
2018-01-29 18:29:34 +01:00
parent 26997607b6
commit 21823bd37a

View File

@@ -86,6 +86,9 @@ protected:
void OnSearch(wxCommandEvent& event); void OnSearch(wxCommandEvent& event);
void OnSearchCancel(wxCommandEvent& event); void OnSearchCancel(wxCommandEvent& event);
void OnSetFocus(wxFocusEvent& event);
void OnKillFocus(wxFocusEvent& event);
wxMenu* CreateTestMenu(); wxMenu* CreateTestMenu();
// (re)create the control // (re)create the control
@@ -171,6 +174,9 @@ void SearchCtrlWidgetsPage::CreateControl()
m_srchCtrl = new wxSearchCtrl(this, -1, wxEmptyString, wxDefaultPosition, m_srchCtrl = new wxSearchCtrl(this, -1, wxEmptyString, wxDefaultPosition,
wxSize(150, -1), style); wxSize(150, -1), style);
m_srchCtrl->Bind(wxEVT_SET_FOCUS, &SearchCtrlWidgetsPage::OnSetFocus, this);
m_srchCtrl->Bind(wxEVT_KILL_FOCUS, &SearchCtrlWidgetsPage::OnKillFocus, this);
} }
void SearchCtrlWidgetsPage::RecreateWidget() void SearchCtrlWidgetsPage::RecreateWidget()
@@ -239,4 +245,18 @@ void SearchCtrlWidgetsPage::OnSearchCancel(wxCommandEvent& event)
event.Skip(); event.Skip();
} }
void SearchCtrlWidgetsPage::OnSetFocus(wxFocusEvent& event)
{
wxLogMessage("Search control got focus");
event.Skip();
}
void SearchCtrlWidgetsPage::OnKillFocus(wxFocusEvent& event)
{
wxLogMessage("Search control lost focus");
event.Skip();
}
#endif // wxUSE_SEARCHCTRL #endif // wxUSE_SEARCHCTRL