summaryrefslogtreecommitdiff
path: root/components/custom/CheckBox.qml
blob: 90a1c38dd53fa9e24c2f97404e236216c8cea42d (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
import QtQuick 1.0
import "./behaviors"

FocusScope {
    id: checkBox

    signal clicked
    property alias pressed: behavior.pressed
    property alias checked: behavior.checked
    property alias containsMouse: behavior.containsMouse
    property bool activeFocusOnPress: false
    property Component background: null
    property Item backgroundItem: backgroundLoader.item

    // implementation

    Loader {
        id: backgroundLoader
        anchors.fill: parent
        property alias styledItem: checkBox
        sourceComponent: background
    }

    ButtonBehavior {
        id: behavior
        focus: true
        anchors.fill: parent
        checkable: true
        onClicked: {if (activeFocusOnPress)checkBox.forceActiveFocus(); checkBox.clicked(); }
    }
    Keys.onSpacePressed: {clicked(); checked = !checked; }
}