From e900e034a36fd1d52b1db6827dc92be00c41cd6b Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Thu, 9 Aug 2018 02:21:27 +0300 Subject: [PATCH] couple Spinbox fixes: - stop resetting value in 'valueFromText'. The issue with such approach is that is is not possible to understand whether value was really changed or, for example, focus did change - instead, propagate validator to TextInput which makes not possible to type bad text (which eliminate the reason for original fix) - specify correct inputMethodHints to guide onscreen keyboards --- interface/resources/qml/controls-uit/SpinBox.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/controls-uit/SpinBox.qml b/interface/resources/qml/controls-uit/SpinBox.qml index f3ae3c5d6e..3d3ea7a75e 100644 --- a/interface/resources/qml/controls-uit/SpinBox.qml +++ b/interface/resources/qml/controls-uit/SpinBox.qml @@ -21,6 +21,7 @@ SpinBox { id: hifi } + inputMethodHints: Qt.ImhFormattedNumbersOnly property int colorScheme: hifi.colorSchemes.light readonly property bool isLightColorScheme: colorScheme === hifi.colorSchemes.light property string label: "" @@ -91,7 +92,6 @@ SpinBox { } valueFromText: function(text, locale) { - spinBox.value = 0; // Force valueChanged signal to be emitted so that validator fires. return Number.fromLocaleString(locale, text)*factor; } @@ -104,6 +104,8 @@ SpinBox { selectedTextColor: hifi.colors.black selectionColor: hifi.colors.primaryHighlight text: spinBox.textFromValue(spinBox.value, spinBox.locale) + suffix + inputMethodHints: spinBox.inputMethodHints + validator: spinBox.validator verticalAlignment: Qt.AlignVCenter leftPadding: spinBoxLabelInside.visible ? 30 : hifi.dimensions.textPadding //rightPadding: hifi.dimensions.spinnerSize