UI: ListView: Improve item selection by click.

This commit is contained in:
Nodir Temirkhodjaev 2018-02-24 16:17:34 +05:00
parent 9ba4a2cd22
commit 09125c1c6d

View File

@ -32,8 +32,14 @@ ListView {
MouseArea {
anchors.fill: parent
onClicked: {
const index = listView.indexAt(listView.contentX + mouse.x,
listView.contentY + mouse.y);
const mouseX = listView.contentX + mouse.x;
const mouseY = listView.contentY + mouse.y;
var index = listView.indexAt(mouseX, mouseY);
if (index < 0) {
index = listView.indexAt(mouseX, mouseY - listView.spacing);
}
if (index >= 0) {
listView.currentIndex = index;
listView.clicked(index);