Changeset View
Changeset View
Standalone View
Standalone View
org.kde.desktop/SpinBox.qml
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 50 | contentItem: TextInput { | |||
---|---|---|---|---|---|
61 | 61 | | |||
62 | readOnly: !controlRoot.editable | 62 | readOnly: !controlRoot.editable | ||
63 | validator: controlRoot.validator | 63 | validator: controlRoot.validator | ||
64 | inputMethodHints: Qt.ImhFormattedNumbersOnly | 64 | inputMethodHints: Qt.ImhFormattedNumbersOnly | ||
65 | 65 | | |||
66 | MouseArea { | 66 | MouseArea { | ||
67 | anchors.fill: parent | 67 | anchors.fill: parent | ||
68 | onPressed: mouse.accepted = false; | 68 | onPressed: mouse.accepted = false; | ||
69 | | ||||
70 | property int wheelDelta: 0 | ||||
71 | | ||||
72 | onExited: wheelDelta = 0 | ||||
69 | onWheel: { | 73 | onWheel: { | ||
70 | if (wheel.pixelDelta.y < 0 || wheel.angleDelta.y < 0) { | 74 | wheelDelta += wheel.angleDelta.y; | ||
71 | controlRoot.decrease(); | 75 | // magic number 120 for common "one click" | ||
72 | } else { | 76 | // See: http://qt-project.org/doc/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop | ||
77 | while (wheelDelta >= 120) { | ||||
78 | wheelDelta -= 120; | ||||
davidedmundson: Does this match the widget? It seems sensible if you you had two physical wheels, if it was… | |||||
73 | controlRoot.increase(); | 79 | controlRoot.increase(); | ||
80 | controlRoot.valueModified(); | ||||
81 | } | ||||
82 | while (wheelDelta <= -120) { | ||||
83 | wheelDelta += 120; | ||||
84 | controlRoot.decrease(); | ||||
85 | controlRoot.valueModified(); | ||||
74 | } | 86 | } | ||
75 | } | 87 | } | ||
88 | | ||||
76 | // Normally the TextInput does this automatically, but the MouseArea on | 89 | // Normally the TextInput does this automatically, but the MouseArea on | ||
77 | // top of it blocks that behavior, so we need to explicitly do it here | 90 | // top of it blocks that behavior, so we need to explicitly do it here | ||
78 | cursorShape: Qt.IBeamCursor | 91 | cursorShape: Qt.IBeamCursor | ||
79 | } | 92 | } | ||
80 | } | 93 | } | ||
81 | 94 | | |||
82 | up.indicator: Item { | 95 | up.indicator: Item { | ||
83 | implicitWidth: parent.height/2 | 96 | implicitWidth: parent.height/2 | ||
Show All 29 Lines |
Does this match the widget? It seems sensible if you you had two physical wheels, if it was exposed as a scroll-ball, this behaviour seems a bit weird.