aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/text/textInputPropertiesAndSignals.qml
blob: d4a7392ebdd4144997e520d0332e8475ae0e82af (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick 2.9
import QtQuick.Layouts 1.1
import "qrc:/quick/shared/" as Shared

Item {
    width: 600; height: 600
    GridLayout {
        columns: 3; rowSpacing: 6; columnSpacing: 6
        anchors { left: parent.left; right: parent.right; top: parent.top; margins: 12 }

        // ----------------------------------------------------
        Text {
            text: "try typing and input methods in the TextInput below:"
            Layout.columnSpan: 3
        }

        // ----------------------------------------------------
        Text {
            text: "TextInput"
        }

        Rectangle {
            Layout.fillWidth: true
            implicitHeight: textInput.implicitHeight + 8
            radius: 4; antialiasing: true
            border.color: "black"; color: "transparent"

            TextInput {
                id: textInput
                anchors.fill: parent; anchors.margins: 4

                onTextEdited: textEditedInd.blip()
                onTextChanged: textChangedInd.blip()
                onPreeditTextChanged: preeditInd.blip()
                onDisplayTextChanged: displayTextInd.blip()
            }

        }

        SignalIndicator {
            id: textEditedInd
            label: "textEdited"
        }

        // ----------------------------------------------------
        Text { text: "text" }

        Text { text: textInput.text; Layout.fillWidth: true }

        SignalIndicator {
            id: textChangedInd
            label: "textChanged"
        }

        // ----------------------------------------------------
        Text { text: "preeditText" }

        Text { text: textInput.preeditText; Layout.fillWidth: true }

        SignalIndicator {
            id: preeditInd
            label: "preeditTextChanged"
        }

        // ----------------------------------------------------
        Text { text: "displayText" }

        Text { text: textInput.displayText; Layout.fillWidth: true }

        SignalIndicator {
            id: displayTextInd
            label: "displayTextChanged"
        }

        // ----------------------------------------------------
        Shared.TextField {
            id: copyFrom
            Layout.column: 1
            Layout.row: 5
            Layout.fillWidth: true
            text: "copy this"
        }

        Shared.Button {
            Layout.column: 2
            Layout.row: 5
            text: "setText"
            onClicked: {
                Qt.inputMethod.reset()
                textInput.text = copyFrom.text
            }
        }
    }
}