So it appears it’s not a bug in the UITK, but in the way it is being used in the browser and in the standalone example (see comment #1). Changing ViewItems.selectedIndices in onSelectedChanged is not a good idea.
I came up with a different approach which solves that issue:
However I’m now seeing another issue: after selecting the first item, then the second one, then the first one again, the 'selected' property of the item doesn’t reflect the current state: the first item is selected, selectedIndices is [0], yet the first delegate’s selected property is false.
So it appears it’s not a bug in the UITK, but in the way it is being used in the browser and in the standalone example (see comment #1). Changing ViewItems. selectedIndices in onSelectedChanged is not a good idea.
I came up with a different approach which solves that issue:
import QtQuick 2.4
import Ubuntu.Components 1.3
ListView { selectMode: true onSelectedIndic esChanged: { selectedIndices .length > 1 && selectedIndex != -1) { selectedIndices .splice( selection. indexOf( selectedIndex) , 1) .selectedIndice s = selection selectedIndices .length > 0) { selectedIndices [0]
id: listview
width: 300
height: 120
model: 2
delegate: ListItem {
ListItemLayout {
title.text: "selected: " + selected
}
}
property int selectedIndex: -1
ViewItems.
ViewItems.
if (ViewItems.
var selection = ViewItems.
selection
selectedIndex = selection[0]
ViewItems
return
}
if (ViewItems.
selectedIndex = ViewItems.
} else {
selectedIndex = -1
}
}
}
However I’m now seeing another issue: after selecting the first item, then the second one, then the first one again, the 'selected' property of the item doesn’t reflect the current state: the first item is selected, selectedIndices is [0], yet the first delegate’s selected property is false.