This breaks the printer demo USB page, it makes it impossible to
change the current item.
That's because the printer demo do `current-item: 1;` to preselect the cat.
But that breaks the property binding that makes current-item follow the
actual-current-item.

 * Revert "move actual-current-item to FocusScope"
   This reverts commit 8240531e6e.

 * Revert "reset StandardListView's current-item if it is out of bounds"
   This reverts commit 9d18882f9d.
This commit is contained in:
Olivier Goffart 2022-05-02 10:20:33 +02:00 committed by Olivier Goffart
parent 894ee5aa91
commit 8a4d6a34ba
2 changed files with 10 additions and 12 deletions

View file

@ -447,7 +447,7 @@ export ListView := ScrollView {
export StandardListView := ListView {
property<[StandardListViewItem]> model;
property<int> current-item: min(fs.actual-current-item, model.length - 1);
property<int> current-item: -1;
for item[idx] in model : Rectangle {
l := HorizontalLayout {
padding: 8px;
@ -462,17 +462,16 @@ export StandardListView := ListView {
touch := TouchArea {
width: parent.width;
height: parent.height;
clicked => { fs.actual-current-item = idx; }
clicked => { current-item = idx; }
}
}
fs := FocusScope {
property<int> actual-current-item: -1;
FocusScope {
key-pressed(event) => {
if (event.text == Keys.UpArrow && current-item > 0) {
actual-current-item -= 1;
current-item -= 1;
return accept;
} else if (event.text == Keys.DownArrow && current-item + 1 < model.length) {
actual-current-item += 1;
current-item += 1;
return accept;
}
reject