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
This commit is contained in:
parent
f74ab0041b
commit
1c7ce07347
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user