Fix the sliders that went out of range when using the arrow keys.

This commit is contained in:
Diego Prado Gesto 2018-08-02 13:12:01 +02:00
parent 847fc33796
commit c14539d63a
2 changed files with 29 additions and 6 deletions

View file

@ -29,6 +29,7 @@ Item {
// value properties
property real maximumValue: 100
property real minimumValue: 0
property bool roundValues: true
property real handleValue: maximumValue
@ -47,6 +48,14 @@ Item {
rangeHandle.width = handle.x - sliderRoot.handleSize
}
function normalizeValue(value) {
if (value > sliderRoot.maximumValue)
return sliderRoot.maximumValue
else if (value < sliderRoot.minimumValue)
return sliderRoot.minimumValue
return value
}
// slider track
Rectangle {
id: track
@ -110,6 +119,8 @@ Item {
// set the slider position based on the value
function setValue (value) {
// Normalize values between range, since using arrow keys will create out-of-the-range values
value = sliderRoot.normalizeValue(value)
UM.SimulationView.setCurrentPath(value)