diff --git a/samples/widgets/toggle.cpp b/samples/widgets/toggle.cpp index 43a4e3f103..385c6a0547 100644 --- a/samples/widgets/toggle.cpp +++ b/samples/widgets/toggle.cpp @@ -39,8 +39,9 @@ #endif #include "wx/artprov.h" -#include "wx/sizer.h" #include "wx/dcmemory.h" +#include "wx/log.h" +#include "wx/sizer.h" #include "icons/toggle.xpm" @@ -102,6 +103,8 @@ protected: void OnButtonReset(wxCommandEvent& event); void OnButtonChangeLabel(wxCommandEvent& event); + void OnToggled(wxCommandEvent& event); + // reset the toggle parameters void Reset(); @@ -165,6 +168,8 @@ wxBEGIN_EVENT_TABLE(ToggleWidgetsPage, WidgetsPage) EVT_CHECKBOX(wxID_ANY, ToggleWidgetsPage::OnCheckOrRadioBox) EVT_RADIOBOX(wxID_ANY, ToggleWidgetsPage::OnCheckOrRadioBox) + + EVT_TOGGLEBUTTON(wxID_ANY, ToggleWidgetsPage::OnToggled) wxEND_EVENT_TABLE() // ============================================================================ @@ -546,6 +551,13 @@ void ToggleWidgetsPage::OnButtonChangeLabel(wxCommandEvent& WXUNUSED(event)) #endif // wxHAS_BITMAPTOGGLEBUTTON } +void ToggleWidgetsPage::OnToggled(wxCommandEvent& event) +{ + wxLogMessage("Button toggled, currently %s (event) or %s (control)", + event.IsChecked() ? "on" : "off", + m_toggle->GetValue() ? "on" : "off"); +} + #ifdef wxHAS_BITMAPTOGGLEBUTTON // ---------------------------------------------------------------------------- // bitmap toggle button stuff