This fix is similar to r66368 for wxMSW and preserves the slider value when
its range changes. This is necessary because while the underlying native
control value doesn't change when the range is, the logical value of wxSlider
does change if it must be inversed as this depends on the range.
See #12765.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66399
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
void wxSlider::SetRange(int minValue, int maxValue)
{
void wxSlider::SetRange(int minValue, int maxValue)
{
+ // Changing the range preserves the value of the native control but may
+ // change our logical value if we're inverting the native value to get it
+ // as ValueInvertOrNot() depends on the range so preserve it before
+ // changing the range.
+ const int valueOld = GetValue();
+
wxString value;
m_rangeMin = minValue;
wxString value;
m_rangeMin = minValue;
SetValue(m_rangeMin);
else if(currentValue > m_rangeMax)
SetValue(m_rangeMax);
SetValue(m_rangeMin);
else if(currentValue > m_rangeMax)
SetValue(m_rangeMax);
+
+ // Ensure that our value didn't change.
+ SetValue(valueOld);