Fix slider event counter in widgets sample
Commit 952e5f3
introduced logging wxEVT_SLIDER events in addition to
scrolling events but the event count was incorrect as the wxEVT_SLIDER
handler and scrolling events handler kept their own event count.
Fix this by using a static member variable shared by both event handlers.
This commit is contained in:
parent
fedc80eee3
commit
fafc5613f4
@ -162,6 +162,8 @@ protected:
|
|||||||
bool IsValidValue(int val) const
|
bool IsValidValue(int val) const
|
||||||
{ return (val >= m_min) && (val <= m_max); }
|
{ return (val >= m_min) && (val <= m_max); }
|
||||||
|
|
||||||
|
static int ms_numSliderEvents;
|
||||||
|
|
||||||
// the slider range
|
// the slider range
|
||||||
int m_min, m_max;
|
int m_min, m_max;
|
||||||
|
|
||||||
@ -201,6 +203,8 @@ private:
|
|||||||
DECLARE_WIDGETS_PAGE(SliderWidgetsPage)
|
DECLARE_WIDGETS_PAGE(SliderWidgetsPage)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int SliderWidgetsPage::ms_numSliderEvents = 0;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// event tables
|
// event tables
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -837,11 +841,8 @@ void SliderWidgetsPage::OnSlider(wxScrollEvent& event)
|
|||||||
wxASSERT_MSG(index >= 0 && (size_t)index < WXSIZEOF(eventNames),
|
wxASSERT_MSG(index >= 0 && (size_t)index < WXSIZEOF(eventNames),
|
||||||
"Unknown slider event" );
|
"Unknown slider event" );
|
||||||
|
|
||||||
|
|
||||||
static int s_numSliderEvents = 0;
|
|
||||||
|
|
||||||
wxLogMessage("Slider event #%d: %s (pos = %d, int value = %d)",
|
wxLogMessage("Slider event #%d: %s (pos = %d, int value = %d)",
|
||||||
s_numSliderEvents++,
|
ms_numSliderEvents++,
|
||||||
eventNames[index],
|
eventNames[index],
|
||||||
event.GetPosition(),
|
event.GetPosition(),
|
||||||
event.GetInt());
|
event.GetInt());
|
||||||
@ -849,10 +850,8 @@ void SliderWidgetsPage::OnSlider(wxScrollEvent& event)
|
|||||||
|
|
||||||
void SliderWidgetsPage::OnSlider(wxCommandEvent& event)
|
void SliderWidgetsPage::OnSlider(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
static int s_numSliderEvents = 0;
|
|
||||||
|
|
||||||
wxLogMessage("Slider event #%d: wxEVT_SLIDER (value = %d)",
|
wxLogMessage("Slider event #%d: wxEVT_SLIDER (value = %d)",
|
||||||
s_numSliderEvents++, event.GetInt());
|
ms_numSliderEvents++, event.GetInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_SLIDER
|
#endif // wxUSE_SLIDER
|
||||||
|
Loading…
Reference in New Issue
Block a user