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:
@@ -88,9 +88,6 @@ 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
|
||||||
@@ -179,9 +176,6 @@ void SearchCtrlWidgetsPage::CreateControl()
|
|||||||
|
|
||||||
m_srchCtrl = new wxSearchCtrl(this, -1, wxEmptyString, wxDefaultPosition,
|
m_srchCtrl = new wxSearchCtrl(this, -1, wxEmptyString, wxDefaultPosition,
|
||||||
FromDIP(wxSize(150, -1)), style);
|
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()
|
void SearchCtrlWidgetsPage::RecreateWidget()
|
||||||
@@ -256,18 +250,4 @@ 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
|
||||||
|
@@ -210,6 +210,10 @@ protected:
|
|||||||
WidgetsPage *CurrentPage();
|
WidgetsPage *CurrentPage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void OnWidgetFocus(wxFocusEvent& event);
|
||||||
|
|
||||||
|
void ConnectToWidgetEvents();
|
||||||
|
|
||||||
// the panel containing everything
|
// the panel containing everything
|
||||||
wxPanel *m_panel;
|
wxPanel *m_panel;
|
||||||
|
|
||||||
@@ -668,6 +672,19 @@ WidgetsPage *WidgetsFrame::CurrentPage()
|
|||||||
return wxStaticCast(page, WidgetsPage);
|
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()
|
WidgetsFrame::~WidgetsFrame()
|
||||||
{
|
{
|
||||||
#if USE_LOG
|
#if USE_LOG
|
||||||
@@ -723,7 +740,10 @@ void WidgetsFrame::OnPageChanged(WidgetsBookCtrlEvent& event)
|
|||||||
wxWindowUpdateLocker noUpdates(curPage);
|
wxWindowUpdateLocker noUpdates(curPage);
|
||||||
curPage->CreateContent();
|
curPage->CreateContent();
|
||||||
curPage->Layout();
|
curPage->Layout();
|
||||||
|
|
||||||
|
ConnectToWidgetEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
// re-apply the attributes to the widget(s)
|
// re-apply the attributes to the widget(s)
|
||||||
curPage->SetUpWidget();
|
curPage->SetUpWidget();
|
||||||
|
|
||||||
@@ -890,6 +910,9 @@ void WidgetsFrame::OnSetBorder(wxCommandEvent& event)
|
|||||||
WidgetsPage *page = CurrentPage();
|
WidgetsPage *page = CurrentPage();
|
||||||
|
|
||||||
page->RecreateWidget();
|
page->RecreateWidget();
|
||||||
|
|
||||||
|
ConnectToWidgetEvents();
|
||||||
|
|
||||||
// re-apply the attributes to the widget(s)
|
// re-apply the attributes to the widget(s)
|
||||||
page->SetUpWidget();
|
page->SetUpWidget();
|
||||||
}
|
}
|
||||||
@@ -1172,6 +1195,14 @@ void WidgetsFrame::OnSetHint(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
#endif // wxUSE_MENUS
|
#endif // wxUSE_MENUS
|
||||||
|
|
||||||
|
void WidgetsFrame::OnWidgetFocus(wxFocusEvent& event)
|
||||||
|
{
|
||||||
|
wxLogMessage("Widgets %s focus",
|
||||||
|
event.GetEventType() == wxEVT_SET_FOCUS ? "got" : "lost");
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// WidgetsPageInfo
|
// WidgetsPageInfo
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user