Merge pull request #2703 from fieldOfView/fix_setting_text_on_focus

Stop SettingTextField from setting values when getting/losing the focus
This commit is contained in:
alekseisasin 2017-10-31 12:47:25 +01:00 committed by GitHub
commit 759c494aaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,14 @@ SettingItem
id: base id: base
property var focusItem: input property var focusItem: input
property string textBeforeEdit
property bool textHasChanged
onFocusReceived:
{
textHasChanged = false;
textBeforeEdit = focusItem.text;
}
contents: Rectangle contents: Rectangle
{ {
id: control id: control
@ -115,12 +123,22 @@ SettingItem
Keys.onReleased: Keys.onReleased:
{ {
propertyProvider.setPropertyValue("value", text) if (text != textBeforeEdit)
{
textHasChanged = true;
}
if (textHasChanged)
{
propertyProvider.setPropertyValue("value", text)
}
} }
onEditingFinished: onEditingFinished:
{ {
propertyProvider.setPropertyValue("value", text) if (textHasChanged)
{
propertyProvider.setPropertyValue("value", text)
}
} }
onActiveFocusChanged: onActiveFocusChanged: