From 8f4ebb4bdcba2df0c41bc45639a4381cad9aebe7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 9 Jul 2020 00:09:43 +0200 Subject: [PATCH] Show wxEVT_TOGGLEBUTTON from toggle button in the widgets sample Allow checking that the events are received as expected. --- samples/widgets/toggle.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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