summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Palettes/Action/HandlerPropertyBaseSlider.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/Authoring/Studio/Palettes/Action/HandlerPropertyBaseSlider.qml')
-rw-r--r--src/Authoring/Studio/Palettes/Action/HandlerPropertyBaseSlider.qml10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Authoring/Studio/Palettes/Action/HandlerPropertyBaseSlider.qml b/src/Authoring/Studio/Palettes/Action/HandlerPropertyBaseSlider.qml
index f1aacbab..13e36516 100644
--- a/src/Authoring/Studio/Palettes/Action/HandlerPropertyBaseSlider.qml
+++ b/src/Authoring/Studio/Palettes/Action/HandlerPropertyBaseSlider.qml
@@ -44,7 +44,7 @@ Row {
property alias sliderMin: slider.from
property alias sliderMax: slider.to
property bool intSlider: false
- property int decimalSlider: 1
+ property int decimalSlider: Math.min(precision(slider.stepSize), 3)
property Item tabItem1: textField
signal previewValue // Indicates desiredValue contains a preview value
@@ -61,6 +61,14 @@ Row {
root.commitValue();
}
+ // get the number of decimals in a float/double
+ function precision(a) {
+ if (!isFinite(a)) return 0;
+ var e = 1, p = 0;
+ while (Math.round(a * e) / e !== a) { e *= 10; p++; }
+ return p;
+ }
+
onValueChanged: {
slider.value = value;
textField.setTextFieldValue();