forked from qt-creator/qt-creator
QmlDesigner: Fix SpinBox dragging
Change-Id: I9d6ef0fa03e7d9a26dea9eb98602238d5dacd28c Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
ff9c170053
commit
9df7a6bdad
@@ -51,33 +51,6 @@ TextInput {
|
|||||||
border.width: 0
|
border.width: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
DragHandler {
|
|
||||||
id: dragHandler
|
|
||||||
target: null
|
|
||||||
acceptedDevices: PointerDevice.Mouse
|
|
||||||
enabled: true
|
|
||||||
|
|
||||||
property int initialValue: 0
|
|
||||||
|
|
||||||
onActiveChanged: {
|
|
||||||
if (active) {
|
|
||||||
initialValue = myControl.value
|
|
||||||
mouseArea.cursorShape = Qt.ClosedHandCursor
|
|
||||||
myControl.drag = true
|
|
||||||
} else {
|
|
||||||
mouseArea.cursorShape = Qt.PointingHandCursor
|
|
||||||
myControl.drag = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onTranslationChanged: {
|
|
||||||
var currValue = myControl.value
|
|
||||||
myControl.value = initialValue + translation.x
|
|
||||||
|
|
||||||
if (currValue !== myControl.value)
|
|
||||||
myControl.valueModified()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: dragModifierWorkaround
|
id: dragModifierWorkaround
|
||||||
Keys.onPressed: function(event) {
|
Keys.onPressed: function(event) {
|
||||||
@@ -86,17 +59,20 @@ TextInput {
|
|||||||
if (event.modifiers & Qt.ControlModifier) {
|
if (event.modifiers & Qt.ControlModifier) {
|
||||||
mouseArea.stepSize = myControl.minStepSize
|
mouseArea.stepSize = myControl.minStepSize
|
||||||
mouseArea.calcValue()
|
mouseArea.calcValue()
|
||||||
|
myControl.valueModified()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.modifiers & Qt.ShiftModifier) {
|
if (event.modifiers & Qt.ShiftModifier) {
|
||||||
mouseArea.stepSize = myControl.maxStepSize
|
mouseArea.stepSize = myControl.maxStepSize
|
||||||
mouseArea.calcValue()
|
mouseArea.calcValue()
|
||||||
|
myControl.valueModified()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Keys.onReleased: function(event) {
|
Keys.onReleased: function(event) {
|
||||||
event.accepted = true
|
event.accepted = true
|
||||||
mouseArea.stepSize = myControl.realStepSize
|
mouseArea.stepSize = myControl.stepSize
|
||||||
mouseArea.calcValue()
|
mouseArea.calcValue()
|
||||||
|
myControl.valueModified()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,13 +93,13 @@ TextInput {
|
|||||||
|
|
||||||
property int initialValue: myControl.value // value on drag operation starts
|
property int initialValue: myControl.value // value on drag operation starts
|
||||||
|
|
||||||
property int pressStartX: 0
|
property real pressStartX: 0.0
|
||||||
property int dragStartX: 0
|
property real dragStartX: 0.0
|
||||||
property int translationX: 0
|
property real translationX: 0.0
|
||||||
|
|
||||||
property int dragDirection: 0
|
property real dragDirection: 0.0
|
||||||
property int totalUnits: 0 // total number of units dragged
|
property real totalUnits: 0.0 // total number of units dragged
|
||||||
property int units: 0
|
property real units: 0.0
|
||||||
|
|
||||||
property real __pixelsPerUnit: textInput.devicePixelRatio * textInput.pixelsPerUnit
|
property real __pixelsPerUnit: textInput.devicePixelRatio * textInput.pixelsPerUnit
|
||||||
|
|
||||||
@@ -176,7 +152,7 @@ TextInput {
|
|||||||
|
|
||||||
mouseArea.translationX += translationX
|
mouseArea.translationX += translationX
|
||||||
mouseArea.calcValue()
|
mouseArea.calcValue()
|
||||||
//myControl.realValueModified()
|
myControl.valueModified()
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: function(mouse) {
|
onClicked: function(mouse) {
|
||||||
|
Reference in New Issue
Block a user