mousepad: add drag support and better click registration
This commit is contained in:
parent
a92112ad47
commit
91c05d0f17
1 changed files with 31 additions and 1 deletions
|
@ -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});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue