fixed the clicked event

This commit is contained in:
ronoaer 2023-10-15 15:54:05 +08:00
parent 8c1835950b
commit a75bd07cd8

View file

@ -34,6 +34,8 @@ Item {
state: "closed"
Drag.active: dragArea.drag.active
Rectangle {
id: draw2Background
@ -46,6 +48,22 @@ Item {
border.width: 1
visible: true
MouseArea {
id: fullArea
anchors.fill: parent
enabled: (root.state === "expanded" || root.state === "opened")
onClicked: {
if (root.state === "expanded") {
root.state = "collapsed"
return
}
if (root.state === "opened") {
root.state = "closed"
return
}
}
Rectangle {
id: semiArea
anchors.top: parent.top
@ -58,6 +76,7 @@ Item {
Rectangle {
id: contentArea
anchors.top: semiArea.bottom
height: contentHeight
radius: 16
@ -75,28 +94,6 @@ Item {
anchors.left: parent.left
color: parent.color
}
}
}
MouseArea {
id: fullArea
anchors.fill: parent
enabled: (root.state === "expanded" || root.state === "opened")
onClicked: {
if (root.state === "expanded") {
root.state = "collapsed"
return
}
if (root.state === "opened") {
root.state = "closed"
return
}
}
}
Drag.active: dragArea.drag.active
MouseArea {
id: dragArea
@ -106,10 +103,10 @@ Item {
cursorShape: (root.state === "opened" || root.state === "expanded") ? Qt.PointingHandCursor : Qt.ArrowCursor
hoverEnabled: true
drag.target: parent
drag.target: root
drag.axis: Drag.YAxis
drag.maximumY: parent.height
drag.minimumY: parent.height - root.height
drag.maximumY: root.height
drag.minimumY: root.height - root.height
/** If drag area is released at any point other than min or max y, transition to the other state */
onReleased: {
@ -146,6 +143,17 @@ Item {
return
}
}
// onEntered: {
// fullArea.enabled = false
// }
// onExited: {
// fullArea.enabled = true
// }
}
}
}
}
onStateChanged: {