QmlDesigner: Fix unchangeable data in cells

* Changes to the cell data are saved if Return or Enter keys are pressed.

Task-number: QDS-11894
Change-Id: Ia3a1ff8f6c9275906736fa1e0638b81c92bea910
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
Shrief Gabr
2024-02-05 13:56:13 +02:00
parent 3e70980279
commit e43b0bcc1f
3 changed files with 40 additions and 5 deletions

View File

@@ -91,6 +91,11 @@ Item {
realStepSize: 1.0
decimals: 6
trailingZeroes: false
onActiveFocusChanged: {
if (realField.activeFocus)
realField.contentItem.focus = true
}
}
}
}
@@ -112,6 +117,11 @@ Item {
from: -2147483647
to: 2147483647
decimals: 0
onActiveFocusChanged: {
if (integerField.activeFocus)
integerField.contentItem.focus = true
}
}
}
}
@@ -149,7 +159,7 @@ Item {
target: editorPopup.editor
function onActiveFocusChanged() {
if (!editorPopup.activeFocus)
if (!editorPopup.editor.activeFocus)
editorPopup.close()
else if (edit)
editorPopup.editor.editValue = edit
@@ -163,6 +173,14 @@ Item {
editorLoader.changesAccepted = false
editorPopup.close()
}
function onReturnPressed() {
editorPopup.close()
}
function onEnterPressed() {
editorPopup.close()
}
}
}

View File

@@ -90,6 +90,11 @@ T.SpinBox {
value: 0
to: 99
function checkAndClearFocus() {
if (!spinBoxIndicatorUp.activeFocus && !spinBoxIndicatorDown.activeFocus && !spinBoxInput.activeFocus)
control.focus = false
}
validator: DoubleValidator {
id: doubleValidator
locale: control.locale.name
@@ -151,7 +156,7 @@ T.SpinBox {
validator: doubleValidator
function handleEditingFinished() {
control.focus = false
control.checkAndClearFocus()
// Keep the dirty state before calling setValueFromInput(),
// it will be set to false (cleared) internally
@@ -165,7 +170,11 @@ T.SpinBox {
control.compressedRealValueModified()
}
onEditingFinished: spinBoxInput.handleEditingFinished()
onEditingFinished: {
spinBoxInput.focus = false
spinBoxInput.handleEditingFinished()
}
onTextEdited: control.dirty = true
}

View File

@@ -69,6 +69,11 @@ T.SpinBox {
editable: true
validator: control.decimals ? doubleValidator : intValidator
function checkAndClearFocus() {
if (!spinBoxIndicatorUp.activeFocus && !spinBoxIndicatorDown.activeFocus && !spinBoxInput.activeFocus)
control.focus = false
}
DoubleValidator {
id: doubleValidator
locale: control.locale.name
@@ -132,7 +137,7 @@ T.SpinBox {
__parentControl: control
function handleEditingFinished() {
control.focus = false
control.checkAndClearFocus()
// Keep the dirty state before calling setValueFromInput(),
// it will be set to false (cleared) internally
@@ -146,7 +151,10 @@ T.SpinBox {
control.compressedValueModified()
}
onEditingFinished: spinBoxInput.handleEditingFinished()
onEditingFinished: {
spinBoxInput.focus = false
spinBoxInput.handleEditingFinished()
}
}
background: Rectangle {