From: Vadim Zeitlin Date: Sun, 19 Dec 2010 14:08:42 +0000 (+0000) Subject: Preserve wxSlider value when changing its range in wxOSX too. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1c7ce073474469e25aedb6c203fdb6f549d18870 Preserve wxSlider value when changing its range in wxOSX too. 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 --- diff --git a/src/osx/slider_osx.cpp b/src/osx/slider_osx.cpp index 68540720b0..705ec7db94 100644 --- a/src/osx/slider_osx.cpp +++ b/src/osx/slider_osx.cpp @@ -166,6 +166,12 @@ void wxSlider::SetValue(int value) 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; @@ -196,6 +202,9 @@ void wxSlider::SetRange(int minValue, int maxValue) SetValue(m_rangeMin); else if(currentValue > m_rangeMax) SetValue(m_rangeMax); + + // Ensure that our value didn't change. + SetValue(valueOld); } // For trackbars only