diff options
| author | J-P Nurmi <jpnurmi@digia.com> | 2013-06-18 21:02:26 +0200 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-06-19 10:08:21 +0200 |
| commit | b0f3a519289511ad89b99a449176a1aff72d2a99 (patch) | |
| tree | 42fdf455b1c35dd2541afc68ff2b0ed483aa80ea /src | |
| parent | eb27f93781df934dc80e363c26313e1f23638670 (diff) | |
| download | qtquickcontrols-b0f3a519289511ad89b99a449176a1aff72d2a99.tar.gz | |
Keep TextField placeholder text visible when focused
This is useful when the widget is focused by default, and also gives
another opportunity to the user to read the message before typing,
removing the need for workarounds like clicking in another text entry to
bring back the placeholder message.
Same as qtbase commit eeb31ad1 for QLineEdit.
Change-Id: I466dd66490e05503b51e208beefd5366b25fd939
Reviewed-by: Caroline Chao <caroline.chao@digia.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/controls/TextField.qml | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml index 32b2d4fb..48981247 100644 --- a/src/controls/TextField.qml +++ b/src/controls/TextField.qml @@ -552,6 +552,20 @@ Control { onClicked: textfield.forceActiveFocus() } + Text { + id: placeholderTextComponent + anchors.fill: textInput + font: textInput.font + horizontalAlignment: textInput.horizontalAlignment + verticalAlignment: textInput.verticalAlignment + opacity: !textInput.text.length ? 1 : 0 + color: __panel ? __panel.placeholderTextColor : "darkgray" + clip: true + elide: Text.ElideRight + renderType: Text.NativeRendering + Behavior on opacity { NumberAnimation { duration: 90 } } + } + TextInput { id: textInput focus: true @@ -574,18 +588,4 @@ Control { onAccepted: textfield.accepted() } - - Text { - id: placeholderTextComponent - anchors.fill: textInput - font: textInput.font - horizontalAlignment: textInput.horizontalAlignment - verticalAlignment: textInput.verticalAlignment - opacity: !textInput.text.length && !textInput.activeFocus ? 1 : 0 - color: __panel ? __panel.placeholderTextColor : "darkgray" - clip: true - elide: Text.ElideRight - renderType: Text.NativeRendering - Behavior on opacity { NumberAnimation { duration: 90 } } - } } |
