diff --git a/src/gui/Base/HTextArea.qml b/src/gui/Base/HTextArea.qml index 999a0f9f..1992d085 100644 --- a/src/gui/Base/HTextArea.qml +++ b/src/gui/Base/HTextArea.qml @@ -17,8 +17,8 @@ TextArea { property var focusItemOnTab: null property var disabledText: null - property string defaultText: "" - readonly property bool changed: text !== defaultText + property var defaultText: null // XXX test me + readonly property bool changed: text !== (defaultText || "") property alias backgroundColor: textAreaBackground.color property color borderColor: theme.controls.textArea.border @@ -28,11 +28,11 @@ TextArea { property string previousDefaultText: "" // private - function reset() { clear(); text = Qt.binding(() => defaultText) } + function reset() { clear(); text = Qt.binding(() => defaultText || "") } function insertAtCursor(text) { insert(cursorPosition, text) } - text: defaultText + text: defaultText || "" opacity: enabled ? 1 : theme.disabledElementsOpacity selectByMouse: true leftPadding: theme.spacing @@ -77,9 +77,10 @@ TextArea { onTextChanged: window.saveState(this) - onActiveFocusChanged: text = text // Break binding + onActiveFocusChanged: + if (defaultText !== null) text = text // Break binding - onDefaultTextChanged: { + onDefaultTextChanged: if (defaultText !== null) { if (text === previousDefaultText) text = Qt.binding(() => defaultText) diff --git a/src/gui/Base/HTextField.qml b/src/gui/Base/HTextField.qml index 99a0d46a..e26a7be3 100644 --- a/src/gui/Base/HTextField.qml +++ b/src/gui/Base/HTextField.qml @@ -5,7 +5,7 @@ import QtQuick.Controls 2.12 TextField { id: field - text: defaultText + text: defaultText || "" opacity: enabled ? 1 : theme.disabledElementsOpacity selectByMouse: true leftPadding: theme.spacing @@ -50,9 +50,10 @@ TextField { onTextChanged: window.saveState(this) - onActiveFocusChanged: text = text // Break binding + onActiveFocusChanged: + if (defaultText !== null) text = text // Break binding - onDefaultTextChanged: { + onDefaultTextChanged: if (defaultText !== null) { if (text === previousDefaultText) text = Qt.binding(() => defaultText) @@ -89,13 +90,13 @@ TextField { property color focusedBorderColor: theme.controls.textField.focusedBorder property var disabledText: null - property string defaultText: "" - readonly property bool changed: text !== defaultText + property var defaultText: null + readonly property bool changed: text !== (defaultText || "") property string previousDefaultText: "" // private - function reset() { clear(); text = Qt.binding(() => defaultText)} + function reset() { clear(); text = Qt.binding(() => defaultText || "")} Binding on color {