Skip to content

Commit

Permalink
Replace onMoved by onValueChanged and remove MouseArea
Browse files Browse the repository at this point in the history
  • Loading branch information
hjtappe committed Apr 4, 2024
1 parent 45f3325 commit 22a5798
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 36 deletions.
38 changes: 4 additions & 34 deletions qmlui/qml/QLCPlusKnob.qml
Expand Up @@ -17,8 +17,8 @@
limitations under the License.
*/

import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick 2.14
import QtQuick.Controls 2.14

import "CanvasDrawFunctions.js" as DrawFuncs
import "."
Expand All @@ -33,6 +33,8 @@ Dial

from: 0
to: 255
stepSize: 1.0
wheelEnabled: true

onPositionChanged: kCanvas.requestPaint()
onHeightChanged: kCanvas.requestPaint()
Expand Down Expand Up @@ -82,38 +84,6 @@ Dial
context.stroke()
context.closePath()
}

MouseArea
{
anchors.fill: parent
z: 2
onWheel: {
//console.log("Wheel delta: " + wheel.angleDelta.y)
var from = sliderObj ? sliderObj.rangeLowLimit : 0
var to = sliderObj ? sliderObj.rangeHighLimit : 255
var sliderValue = sliderObj ? sliderObj.value : 128

if (wheel.angleDelta.y > 0) {
if (sliderObj && sliderValue < to) {
sliderObj.value += 1
}
} else {
if (sliderObj && sliderValue > from) {
sliderObj.value -= 1
}
}
}
onPressed: {
mouse.accepted = false
}
onPositionChanged: {
mouse.accepted = false
kCanvas.requestPaint()
}
onReleased: {
mouse.accepted = false
}
}
}

handle: Rectangle {
Expand Down
4 changes: 2 additions & 2 deletions qmlui/qml/virtualconsole/VCSliderItem.qml
Expand Up @@ -17,7 +17,7 @@
limitations under the License.
*/

import QtQuick 2.0
import QtQuick 2.14
import QtQuick.Layouts 1.1

import org.qlcplus.classes 1.0
Expand Down Expand Up @@ -149,7 +149,7 @@ VCWidgetItem
to: sliderObj ? sliderObj.rangeHighLimit : 255
value: sliderValue

onMoved: if (sliderObj) sliderObj.value = value // position * 255
onValueChanged: if (sliderObj) sliderObj.value = value
}

// widget name text box
Expand Down

0 comments on commit 22a5798

Please sign in to comment.