shift-shell/touchscreentest/main.qml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
1.1 KiB
QML
Raw Normal View History

2017-09-14 08:23:49 +00:00
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
2017-09-14 10:19:31 +00:00
property real startX
property real startY
2017-09-14 08:23:49 +00:00
function format(text, mouse) {
2017-09-14 10:19:31 +00:00
return text + " " + Math.round(mouse.x*100)/100 + " " + Math.round(mouse.y*100)/100 +"\nInitial: " + Math.round(startX*100)/100 +" "+Math.round(startY*100)/100
2017-09-14 08:23:49 +00:00
}
MouseArea {
anchors.fill: parent
2017-09-14 10:19:31 +00:00
onPressed: {
startX = mouse.x;
startY = mouse.y;
label.text = format("MOUSE PRESS", mouse);
}
2017-09-14 08:23:49 +00:00
onPositionChanged: label.text = format("MOUSE Position change", mouse)
onReleased: label.text = label.text = format("MOUSE Release", mouse)
onCanceled: label.text = label.text = format("MOUSE Cancel", mouse)
Label {
id: label
anchors.fill:parent
font.pointSize: 20
verticalAlignment: Text.AlignHCenter
horizontalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
}
}
}