Jak włączyć zdarzenia związane z najechaniem myszką podrzędną w nadrzędnej myszy MouseArea za pomocą QML?
Chcę zaimplementować następujący scenariusz w QML.
Oto przykładowy / uproszczony pełnomocnik doListView
element:
Component {
Item {
id: container
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: {
container.ListView.view.currentIndex = index
container.forceActiveFocus();
}
onEntered: {
actionList.state = "SHOW";
myItem.state = "HOVER"
}
onExited: {
actionList.state = "HIDE";
myItem.state = "NORMAL"
}
Rectangle {
id: myItem
color: "gray"
anchors.fill: parent
Row {
id: actionList
spacing: 5; anchors.fill: parent
Image {
id: helpAction
source: "" //Some image address
width: 16; height: 16; fillMode: Image.PreserveAspectFit
states: [
State {
name: "NORMAL"
PropertyChanges { target: helpAction; opacity: 0.7 }
},
State {
name: "HOVER"
PropertyChanges { target: helpAction; opacity: 1.0 }
}
]
MouseArea {
hoverEnabled: true
anchors.fill: parent
onEntered: {
parent.state = "HOVER";
}
onExited: {
parent.state = "NORMAL";
}
}
states: [
State {
name: "SHOW"
PropertyChanges { target: actionList; visible: false }
},
State {
name: "HIDE"
PropertyChanges { target: actionList; visible: true }
}
]
}
//Other action buttons...
states: [
// `NORMAL` and `HOVER` states definition here...
]
}
}
}
}
Ale mam problem zMouseArea
.
WewnętrznyMouseArea
(przycisk akcji) nie działa poprawnie dlaentered
zdarzenie. Gdy mysz wchodzi na przycisk akcji, na zewnątrzMouseArea
pożaryexited
zdarzenie.
Czy w moim kodzie jest jakiś błąd? Bardziej ogólnie, jak mogę wdrożyć taki scenariusz w QML?