Originally Posted by
wysota
You need to put the mouse area on the list view and also make sure all mouse events are propagated from that mouse area to the view by ignoring incoming events in the mouse area element.
Thank you for your response.
However, what I did was put the MouseArea on delegate item then send a signal from onPressAndHold with mouseX and mouseY parameters to the ListView.
Then used mapFromItem on the listItem.
Item {
id: listItem
anchors {
top: parent.top
left: parent.left
right: parent.right
bottom: parent.bottom
}
ListView {
id: list
anchors.fill: parent
currentIndex: -1
clip: true
model: itemModel
delegate: ItemDelegate {
onMenuPosition: {
var pos = listItem.mapFromItem(list.currentItem, mouseX, mouseY)
menu.x = pos.x
menu.y = pos.y
}
}
boundsBehavior: Flickable.StopAtBounds
CustomMenu {
id: menu
z: 100
parent: list
model: menuModel
}
}
}
Item {
id: listItem
anchors {
top: parent.top
left: parent.left
right: parent.right
bottom: parent.bottom
}
ListView {
id: list
anchors.fill: parent
currentIndex: -1
clip: true
model: itemModel
delegate: ItemDelegate {
onMenuPosition: {
var pos = listItem.mapFromItem(list.currentItem, mouseX, mouseY)
menu.x = pos.x
menu.y = pos.y
}
}
boundsBehavior: Flickable.StopAtBounds
CustomMenu {
id: menu
z: 100
parent: list
model: menuModel
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks