Fix generation of extraneous wxEVT_SLIDER events in wxMSW

Don't send the event when it's redundant, i.e. doesn't really notify
about the change in the slider value.

Also add a test case for wxEVT_SLIDER and show these events in the
widgets sample.

Closes https://github.com/wxWidgets/wxWidgets/pull/2080

Closes #18929.
This commit is contained in:
PB
2020-10-07 18:18:55 +02:00
committed by Vadim Zeitlin
parent 7ed330a197
commit 952e5f32cd
3 changed files with 48 additions and 5 deletions

View File

@@ -120,6 +120,7 @@ protected:
void OnCheckOrRadioBox(wxCommandEvent& event);
void OnSlider(wxScrollEvent& event);
void OnSlider(wxCommandEvent& event);
void OnUpdateUIValueButton(wxUpdateUIEvent& event);
void OnUpdateUIMinMaxButton(wxUpdateUIEvent& event);
@@ -230,6 +231,7 @@ wxBEGIN_EVENT_TABLE(SliderWidgetsPage, WidgetsPage)
EVT_UPDATE_UI(SliderPage_CurValueText, SliderWidgetsPage::OnUpdateUICurValueText)
EVT_COMMAND_SCROLL(SliderPage_Slider, SliderWidgetsPage::OnSlider)
EVT_SLIDER(SliderPage_Slider, SliderWidgetsPage::OnSlider)
EVT_CHECKBOX(wxID_ANY, SliderWidgetsPage::OnCheckOrRadioBox)
EVT_RADIOBOX(wxID_ANY, SliderWidgetsPage::OnCheckOrRadioBox)
@@ -845,4 +847,12 @@ void SliderWidgetsPage::OnSlider(wxScrollEvent& event)
event.GetInt());
}
void SliderWidgetsPage::OnSlider(wxCommandEvent& event)
{
static int s_numSliderEvents = 0;
wxLogMessage("Slider event #%d: wxEVT_SLIDER (value = %d)",
s_numSliderEvents++, event.GetInt());
}
#endif // wxUSE_SLIDER