finally getting the hover down with color changing

This commit is contained in:
talksik
2024-02-09 10:46:57 -08:00
parent fbaf2da3d7
commit 9e11952bf0
+26 -12
View File
@@ -40,31 +40,45 @@ Window {
delegate: Item { delegate: Item {
id: listItem id: listItem
height: 20 height: 20
width: 100 width: 400
property bool hovered: false property bool hovered: false
required property string name required property string name
property bool isConnected: false
Rectangle {
anchors.fill: parent
color: hovered ? "blue" : "transparent"
Text {
text: listItem.name
color: listItem.hovered ? "white" : "black"
}
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onEntered: listItem.hovered = true onEntered: {
console.log("on hover")
listItem.hovered = true
}
onExited: listItem.hovered = false onExited: listItem.hovered = false
onClicked: console.log("Clicked!") onClicked: console.log("Clicked!")
}
Rectangle {
anchors.fill: parent
color: listItem.hovered ? "blue" : "transparent"
transitions: Transition { transitions: Transition {
ColorAnimation { target: parent; property: "color"; duration: 200 } ColorAnimation { target: parent; property: "color"; duration: 200 }
} }
RowLayout {
anchors.fill: parent
Text {
Layout.fillWidth: true
text: listItem.name
color: listItem.hovered ? "white" : "black"
}
Button {
visible: !listItem.isConnected
text: "Connect"
onClicked: console.log("connecting to " + listItem.name)
}
}
}
} }
} }
} }