diff options
author | Henning Gruendl <henning.gruendl@qt.io> | 2023-04-26 17:07:32 +0200 |
---|---|---|
committer | Henning Gründl <henning.gruendl@qt.io> | 2023-04-27 15:34:07 +0000 |
commit | ba91f9e3e08a90164403f959b5c778dd8f109f76 (patch) | |
tree | 0a3b2f5c0dd97cf64ce4e335992cf3bbb9a91708 | |
parent | 8401dc64b50262a55739f827988835f2ff2bfd41 (diff) |
QmlDesigner: Fix SpinBox value reset on focus loss
Task-number: QDS-9770
Change-Id: I8a4d73e7abe8dbb5c62c571fc9980a0f78a5f819
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
-rw-r--r-- | share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/RealSpinBox.qml | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/RealSpinBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/RealSpinBox.qml index aba99f75ffa..2f219a411da 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/RealSpinBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/RealSpinBox.qml @@ -121,7 +121,7 @@ T.SpinBox { height: control.spinBoxIndicatorVisible ? control.__spinBoxIndicatorHeight : 0 realEnabled: (control.realFrom < control.realTo) ? (control.realValue < control.realTo) - : (control.realValue > control.realTo) + : (control.realValue > control.realTo) } down.indicator: RealSpinBoxIndicator { @@ -138,7 +138,7 @@ T.SpinBox { height: control.spinBoxIndicatorVisible ? control.__spinBoxIndicatorHeight : 0 realEnabled: (control.realFrom < control.realTo) ? (control.realValue > control.realFrom) - : (control.realValue < control.realFrom) + : (control.realValue < control.realFrom) } contentItem: RealSpinBoxInput { @@ -284,26 +284,26 @@ T.SpinBox { control.setRealValue(control.realValue) // sanitize and clamp realValue spinBoxInput.text = control.textFromValue(control.realValue, control.locale) control.value = 0 // Without setting value back to 0, it can happen that one of - // the indicator will be disabled due to range logic. + // the indicator will be disabled due to range logic. } onRealValueModified: myTimer.restart() onFocusChanged: { - if (control.focus) { + if (control.focus) control.dirty = false - } else { - // Make sure displayed value is correct after focus loss, as onEditingFinished - // doesn't trigger when value is something validator doesn't accept. - spinBoxInput.text = control.textFromValue(control.realValue, control.locale) - - if (control.dirty) - spinBoxInput.handleEditingFinished() - } } onDisplayTextChanged: spinBoxInput.text = control.displayText onActiveFocusChanged: { if (control.activeFocus) { // QTBUG-75862 && mySpinBox.focusReason === Qt.TabFocusReason) control.preFocusText = spinBoxInput.text spinBoxInput.selectAll() + } else { + // Make sure displayed value is correct after focus loss, as onEditingFinished + // doesn't trigger when value is something validator doesn't accept. + if (spinBoxInput.text === "") + spinBoxInput.text = control.textFromValue(control.realValue, control.locale) + + if (control.dirty) + spinBoxInput.handleEditingFinished() } } @@ -373,8 +373,8 @@ T.SpinBox { value = Math.round(value) control.realValue = control.clamp(value, - control.validator.bottom, - control.validator.top) + control.validator.bottom, + control.validator.top) } function realDecrease() { |