summaryrefslogtreecommitdiff
path: root/SDL_Core/src/components/qt_hmi/References/Work/bananasnacks/qml/Bananas/Components/TextEntry.qml
blob: 774894c137507d024e0b9c9f12ada4826448316c (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
import QtQuick 2.0

Item {
    id: textentry
    property alias input_border: search_text_box.border
    property alias autocompleteModel: autocomplete.model
    property alias text: search_text_box.text
    signal selected
    anchors.fill: parent

    TextBox {
        id: search_text_box
        icon: "../Assets/SearchIcon.png"
        anchors.top: parent.top
        width: parent.width - 160
        anchors.horizontalCenter: parent.horizontalCenter

        onTextChanged: if (autocomplete.model) autocomplete.model.setSearchString(text)
    }

    BackButton {
        anchors.top: search_text_box.top
        anchors.topMargin: 1
        anchors.right: search_text_box.left
        anchors.rightMargin: 10
        onPress: section.state = 'menu'
    }

    ImageButton {
        anchors.top: search_text_box.top
        anchors.topMargin: 1
        icon: "../Assets/DeleteIcon.png"
        anchors.left: search_text_box.right
        anchors.leftMargin: 10
        height: 42

        onPress: search_text_box.text = search_text_box.text.replace(/.$/, '')
    }

    Keyboard {
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.topMargin: 40
        anchors.top: search_text_box.bottom

        onLetterClicked: search_text_box.text += letter
        onGo: textentry.selected()
    }

    ListView {
        id: autocomplete
        anchors.top: search_text_box.bottom
        anchors.bottom: parent.bottom
        anchors.right: search_text_box.right
        anchors.left: search_text_box.left
        clip: true
        visible: (count > 0 && count <= 5)

        delegate: Button {
            text: model.text
            width: parent.width
            textAnchors.horizontalCenter: undefined
            textAnchors.left: clickable.left
            textAnchors.leftMargin: 70

            onPress: {
                autocomplete.model.selected = model.text;
                textentry.selected()
            }
        }
    }
}