aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/shared/TextField.qml
blob: 66854c89bf6efd6b45d72ffb19d3ecdc343ce6d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick

Item {
    id: root

    property alias textInput: textInput
    property alias text: textInput.text
    signal accepted
    signal downPressed
    implicitWidth: textInput.implicitWidth + rect.radius * 2
    implicitHeight: textInput.implicitHeight

    function copyAll() {
        textInput.selectAll()
        textInput.copy()
    }

    SystemPalette { id: palette }
    height: textInput.implicitHeight + 8
    clip: true

    Rectangle {
        id: rect
        anchors.fill: parent
        radius: height / 4
        color: palette.button
        border.color: Qt.darker(palette.button, 1.5)
    }

    TextInput {
        id: textInput
        color: palette.text
        anchors.fill: parent
        anchors.leftMargin: rect.radius
        anchors.rightMargin: rect.radius
        verticalAlignment: Text.AlignVCenter
        onAccepted: root.accepted()
        Keys.onDownPressed: root.downPressed()
    }
}