Commit 91c05d0f authored by Piyush Aggarwal's avatar Piyush Aggarwal 🎮
Browse files

mousepad: add drag support and better click registration

parent a92112ad
Pipeline #70560 passed with stage
in 4 minutes and 48 seconds
......@@ -29,6 +29,8 @@ Kirigami.Page
Layout.fillWidth: true
Layout.fillHeight: true
property var lastPos: Qt.point(-1, -1)
property var pressedPos: Qt.point(-1, -1)
property var releasedPos: Qt.point(-1, -1)
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
......@@ -37,7 +39,11 @@ Kirigami.Page
var packet = {};
switch (mouse.button) {
case Qt.LeftButton:
clickType = "singleclick";
if (pressedPos == releasedPos) {
clickType = "singleclick";
pressedPos = Qt.point(-1, -1);
releasedPos = Qt.point(-1, -1);
}
break;
case Qt.RightButton:
clickType = "rightclick";
......@@ -56,6 +62,24 @@ Kirigami.Page
}
}
onDoubleClicked: {
var clickType = "";
var packet = {};
switch (mouse.button) {
case Qt.LeftButton:
clickType = "singlehold";
break;
default:
console.log("This click input is not handled yet!");
break;
}
if (clickType) {
packet[clickType] = true;
mousepad.pluginInterface.sendCommand(packet);
}
}
onPositionChanged: {
if (lastPos.x > -1) {
// console.log("move", mouse.x, mouse.y, lastPos)
......@@ -66,6 +90,10 @@ Kirigami.Page
lastPos = Qt.point(mouse.x, mouse.y);
}
onPressed: {
pressedPos = Qt.point(mouse.x, mouse.y);
}
onWheel: {
var packet = {};
packet["scroll"] = true;
......@@ -76,6 +104,8 @@ Kirigami.Page
onReleased: {
lastPos = Qt.point(-1, -1)
releasedPos = Qt.point(mouse.x, mouse.y);
mousepad.pluginInterface.sendCommand({"singlerelease": true});
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment