summaryrefslogtreecommitdiffstats
path: root/examples/declarative/mouseregion/mouse.qml
blob: 9581da23e27b02d703ab2a6fe190c314ebc46726 (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
<Rect color="white" width="200" height="200">
    <Rect width="50" height="50" color="red">
        <Text text="Click" anchors.centeredIn="{parent}"/>
        <MouseRegion onPressed="print('press (x: ' + mouse.x + ' y: ' + mouse.y + ')')"
                     onReleased="print('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')')"
                     onClicked="print('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')')"
                     onDoubleClicked="print('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')')"
                     onPressAndHold="print('press and hold')"
                     onExitedWhilePressed="print('exiting while pressed')"
                     onReenteredWhilePressed="print('reentering while pressed')" anchors.fill="{parent}"/>
    </Rect>
    <Rect y="100" width="50" height="50" color="blue">
        <Text text="Drag" anchors.centeredIn="{parent}"/>
        <MouseRegion drag.target="{parent}"
                     drag.axis="x" drag.xmin="0" drag.xmax="150"
                     onPressed="print('press')"
                     onReleased="print('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')')"
                     onClicked="print('click' + '(wasHeld: ' + mouse.wasHeld + ')')"
                     onDoubleClicked="print('double click')"
                     onPressAndHold="print('press and hold')"
                     onExitedWhilePressed="print('exiting while pressed')"
                     onReenteredWhilePressed="print('reentering while pressed')" anchors.fill="{parent}"/>
    </Rect>
</Rect>