KnobControl: fix changing value by using the mouse wheel

Workaround for QML bug
This commit is contained in:
Casper Jeukendrup 2021-12-03 20:03:26 +01:00 committed by pereverzev+v
parent 19bc67beee
commit f7f35a34aa

View file

@ -165,6 +165,7 @@ Dial {
}
MouseArea {
id: mouseArea
anchors.fill: parent
onDoubleClicked: {
root.newValueRequested(0)
@ -197,5 +198,13 @@ Dial {
let bounded = Math.max(root.from, Math.min(newValue, root.to))
root.newValueRequested(bounded)
}
// We also listen for wheel events here, but for a different reason:
// Qml Dial has a bug that it doesn't emit moved() when the value is changed through a wheel event.
// So when we see a wheel event, we let the dial handle it, but we will account for emitting the signal.
onWheel: function(wheel) {
wheel.accepted = false
Qt.callLater(function() { root.newValueRequested(Math.round(value)) })
}
}
}