Test focus event generation for all pages of the widgets sample
Previously this was done only for wxSearchCtrl, extend this now to all the widgets in order to be able to check whether the expected events are generated.
This commit is contained in:
parent
fb71adab04
commit
25a2bae836
2 changed files with 31 additions and 20 deletions
|
|
@ -88,9 +88,6 @@ protected:
|
|||
void OnSearch(wxCommandEvent& event);
|
||||
void OnSearchCancel(wxCommandEvent& event);
|
||||
|
||||
void OnSetFocus(wxFocusEvent& event);
|
||||
void OnKillFocus(wxFocusEvent& event);
|
||||
|
||||
wxMenu* CreateTestMenu();
|
||||
|
||||
// (re)create the control
|
||||
|
|
@ -179,9 +176,6 @@ void SearchCtrlWidgetsPage::CreateControl()
|
|||
|
||||
m_srchCtrl = new wxSearchCtrl(this, -1, wxEmptyString, wxDefaultPosition,
|
||||
FromDIP(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()
|
||||
|
|
@ -256,18 +250,4 @@ void SearchCtrlWidgetsPage::OnSearchCancel(wxCommandEvent& event)
|
|||
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
|
||||
|
|
|
|||
|
|
@ -210,6 +210,10 @@ protected:
|
|||
WidgetsPage *CurrentPage();
|
||||
|
||||
private:
|
||||
void OnWidgetFocus(wxFocusEvent& event);
|
||||
|
||||
void ConnectToWidgetEvents();
|
||||
|
||||
// the panel containing everything
|
||||
wxPanel *m_panel;
|
||||
|
||||
|
|
@ -668,6 +672,19 @@ WidgetsPage *WidgetsFrame::CurrentPage()
|
|||
return wxStaticCast(page, WidgetsPage);
|
||||
}
|
||||
|
||||
void WidgetsFrame::ConnectToWidgetEvents()
|
||||
{
|
||||
const Widgets& widgets = CurrentPage()->GetWidgets();
|
||||
|
||||
for ( Widgets::const_iterator it = widgets.begin();
|
||||
it != widgets.end();
|
||||
++it )
|
||||
{
|
||||
(*it)->Bind(wxEVT_SET_FOCUS, &WidgetsFrame::OnWidgetFocus, this);
|
||||
(*it)->Bind(wxEVT_KILL_FOCUS, &WidgetsFrame::OnWidgetFocus, this);
|
||||
}
|
||||
}
|
||||
|
||||
WidgetsFrame::~WidgetsFrame()
|
||||
{
|
||||
#if USE_LOG
|
||||
|
|
@ -723,7 +740,10 @@ void WidgetsFrame::OnPageChanged(WidgetsBookCtrlEvent& event)
|
|||
wxWindowUpdateLocker noUpdates(curPage);
|
||||
curPage->CreateContent();
|
||||
curPage->Layout();
|
||||
|
||||
ConnectToWidgetEvents();
|
||||
}
|
||||
|
||||
// re-apply the attributes to the widget(s)
|
||||
curPage->SetUpWidget();
|
||||
|
||||
|
|
@ -890,6 +910,9 @@ void WidgetsFrame::OnSetBorder(wxCommandEvent& event)
|
|||
WidgetsPage *page = CurrentPage();
|
||||
|
||||
page->RecreateWidget();
|
||||
|
||||
ConnectToWidgetEvents();
|
||||
|
||||
// re-apply the attributes to the widget(s)
|
||||
page->SetUpWidget();
|
||||
}
|
||||
|
|
@ -1172,6 +1195,14 @@ void WidgetsFrame::OnSetHint(wxCommandEvent& WXUNUSED(event))
|
|||
|
||||
#endif // wxUSE_MENUS
|
||||
|
||||
void WidgetsFrame::OnWidgetFocus(wxFocusEvent& event)
|
||||
{
|
||||
wxLogMessage("Widgets %s focus",
|
||||
event.GetEventType() == wxEVT_SET_FOCUS ? "got" : "lost");
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// WidgetsPageInfo
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue