diff --git a/resources/qml/MachineSettings/NumericTextFieldWithUnit.qml b/resources/qml/MachineSettings/NumericTextFieldWithUnit.qml index bad7f5a867..c46116e520 100644 --- a/resources/qml/MachineSettings/NumericTextFieldWithUnit.qml +++ b/resources/qml/MachineSettings/NumericTextFieldWithUnit.qml @@ -156,7 +156,13 @@ UM.TooltipArea const value = propertyProvider.properties.value return value ? value : "" } - validator: RegExpValidator { regExp: allowNegativeValue ? /-?[0-9\.,]{0,6}/ : /[0-9\.,]{0,6}/ } + validator: DoubleValidator + { + bottom: allowNegativeValue ? Number.NEGATIVE_INFINITY : 0 + top: allowPositiveValue ? Number.POSITIVE_INFINITY : 0 + decimals: 6 + notation: DoubleValidator.StandardNotation + } onEditingFinished: editingFinishedFunction() diff --git a/resources/qml/MachineSettings/PrintHeadMinMaxTextField.qml b/resources/qml/MachineSettings/PrintHeadMinMaxTextField.qml index 8919271f05..a08fa92c78 100644 --- a/resources/qml/MachineSettings/PrintHeadMinMaxTextField.qml +++ b/resources/qml/MachineSettings/PrintHeadMinMaxTextField.qml @@ -55,10 +55,23 @@ NumericTextFieldWithUnit valueText: axisValue + Connections + { + target: textField + onActiveFocusChanged: + { + // When this text field loses focus and the entered text is not valid, make sure to recreate the binding to + // show the correct value. + if (!textField.activeFocus && !textField.acceptableInput) + { + valueText = axisValue + } + } + } + editingFinishedFunction: function() { var polygon = JSON.parse(propertyProvider.properties.value) - var newValue = parseFloat(valueText.replace(',', '.')) if (axisName == "x") // x min/x max @@ -79,5 +92,8 @@ NumericTextFieldWithUnit propertyProvider.setPropertyValue("value", polygon_string) forceUpdateOnChangeFunction() } + + // Recreate the binding to show the correct value. + valueText = axisValue } }