Index: sources/gui/qml/components/RangeSlider.qml =================================================================== diff -u -r0954c208c72d1568e7609d55f05f5f5b93cf72ee -r0f28ae04f739c859dc850a9baa430c62251629d6 --- sources/gui/qml/components/RangeSlider.qml (.../RangeSlider.qml) (revision 0954c208c72d1568e7609d55f05f5f5b93cf72ee) +++ sources/gui/qml/components/RangeSlider.qml (.../RangeSlider.qml) (revision 0f28ae04f739c859dc850a9baa430c62251629d6) @@ -169,6 +169,11 @@ /// \details regarding the current mouse x position selects the correct handler and updated the bound value. /// \param x : mouse x position. function setBound(x) { + if(curHandler === RangeSlider.HandlerOption.None) { + // The user did not select a handle + return + } + let mValue = setValue(x) // console.debug( maxValue - minValue, minValue, value, maxValue ) if ( maxValue - minValue <= gapValue ) { @@ -182,9 +187,10 @@ let minDiff = Math.abs(minValue - mValue) let maxDiff = Math.abs(maxValue - mValue) + if ( minDiff === maxDiff ) { if ( curHandler === RangeSlider.HandlerOption.Max ) checkLimitsMaxValueBounds(mValue) - else checkLimitsMinValueBounds(mValue) + else checkLimitsMinValueBounds(mValue) } else { // console.debug( minDiff, minValue, value, maxValue, maxDiff ) @@ -200,14 +206,12 @@ } function checkLimitsMinValueBounds ( vValue ) { - curHandler = RangeSlider.HandlerOption.Min if ( vValue < minValueLowerBound ) { minValue = minValueLowerBound; return } if ( vValue > minValueUpperBound ) { minValue = minValueUpperBound; return } setMinvalue(vValue) } function checkLimitsMaxValueBounds ( vValue ) { - curHandler = RangeSlider.HandlerOption.Max if ( vValue < maxValueLowerBound ) { maxValue = maxValueLowerBound; return } if ( vValue > maxValueUpperBound ) { maxValue = maxValueUpperBound; return } setMaxValue(vValue) @@ -251,22 +255,13 @@ onDragged: { // Add in the x position of the range rect to account for it moving on the // main slider line - setBound(vMouseEvent.x + _rangeRect.x) + setBound(vMouseEvent.x + _rangeRect.x - _rangeRect.leftRightTouchMargin) } - onPressed: { - // Add in the x position of the range rect to account for it moving on the - // main slider line - setBound(vMouseEvent.x + _rangeRect.x) - } - onClicked: { - // Add in the x position of the range rect to account for it moving on the - // main slider line - setBound(vMouseEvent.x + _rangeRect.x) - } + onReleased: { // Add in the x position of the range rect to account for it moving on the // main slider line - setBound(vMouseEvent.x + _rangeRect.x) + setBound(vMouseEvent.x + _rangeRect.x - _rangeRect.leftRightTouchMargin) } } @@ -287,16 +282,11 @@ } onDragged: { - setBound(vMouseEvent.x ) + setBound(vMouseEvent.x - _rangeRect.leftRightTouchMargin) } - onClicked: { - setBound(vMouseEvent.x ) - } - onPressed: { - setBound(vMouseEvent.x ) - } + onReleased: { - setBound(vMouseEvent.x) + setBound(vMouseEvent.x - _rangeRect.leftRightTouchMargin) } /// Left most maximum range vertical edge @@ -323,7 +313,7 @@ /// Left most handler Rectangle { id: _handlerLeft - property real diameter : _root.diameter + property real diameter : _root.diameter anchors.verticalCenter : parent.verticalCenter anchors.horizontalCenter: _rangeRect.left @@ -336,11 +326,24 @@ width : 4 color : Colors.textMain } + MouseArea { + propagateComposedEvents: true // propagate the click to the lower layer + anchors.fill: parent + onPressed: { + mouse.accepted = false // indicate that the current component did not handle the mouse action, propagate + _root.curHandler = RangeSlider.HandlerOption.Min + } + + onReleased: { + mouse.accepted = false // indicate that the current component did not handle the mouse action, propagate + _root.curHandler = RangeSlider.HandlerOption.None + } + } } /// Right most handler Rectangle { id: _handlerRight - property real diameter : _root.diameter + property real diameter : _root.diameter anchors.verticalCenter : parent.verticalCenter anchors.horizontalCenter : _rangeRect.right @@ -353,5 +356,17 @@ width : 4 color : Colors.textMain } + MouseArea { + propagateComposedEvents: true // propagate the click to the lower layer + anchors.fill: parent + onPressed:{ + mouse.accepted = false // indicate that the current component did not handle the mouse action, propagate + _root.curHandler = RangeSlider.HandlerOption.Max + } + onReleased: { + mouse.accepted = false // indicate that the current component did not handle the mouse action, propagate + _root.curHandler = RangeSlider.HandlerOption.None + } + } } }