Show wxEVT_TOGGLEBUTTON from toggle button in the widgets sample

Allow checking that the events are received as expected.
This commit is contained in:
Vadim Zeitlin 2020-07-09 00:09:43 +02:00
parent 06ffd1dbab
commit 8f4ebb4bdc

View File

@ -39,8 +39,9 @@
#endif #endif
#include "wx/artprov.h" #include "wx/artprov.h"
#include "wx/sizer.h"
#include "wx/dcmemory.h" #include "wx/dcmemory.h"
#include "wx/log.h"
#include "wx/sizer.h"
#include "icons/toggle.xpm" #include "icons/toggle.xpm"
@ -102,6 +103,8 @@ protected:
void OnButtonReset(wxCommandEvent& event); void OnButtonReset(wxCommandEvent& event);
void OnButtonChangeLabel(wxCommandEvent& event); void OnButtonChangeLabel(wxCommandEvent& event);
void OnToggled(wxCommandEvent& event);
// reset the toggle parameters // reset the toggle parameters
void Reset(); void Reset();
@ -165,6 +168,8 @@ wxBEGIN_EVENT_TABLE(ToggleWidgetsPage, WidgetsPage)
EVT_CHECKBOX(wxID_ANY, ToggleWidgetsPage::OnCheckOrRadioBox) EVT_CHECKBOX(wxID_ANY, ToggleWidgetsPage::OnCheckOrRadioBox)
EVT_RADIOBOX(wxID_ANY, ToggleWidgetsPage::OnCheckOrRadioBox) EVT_RADIOBOX(wxID_ANY, ToggleWidgetsPage::OnCheckOrRadioBox)
EVT_TOGGLEBUTTON(wxID_ANY, ToggleWidgetsPage::OnToggled)
wxEND_EVENT_TABLE() wxEND_EVENT_TABLE()
// ============================================================================ // ============================================================================
@ -546,6 +551,13 @@ void ToggleWidgetsPage::OnButtonChangeLabel(wxCommandEvent& WXUNUSED(event))
#endif // wxHAS_BITMAPTOGGLEBUTTON #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 #ifdef wxHAS_BITMAPTOGGLEBUTTON
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// bitmap toggle button stuff // bitmap toggle button stuff