slint/internal/compiler/widgets/material-base/widget-listview.slint
Olivier Goffart 7947d44e59 Run the syntax_updater on our widgets
This is commit is just the output of running the syntax updater on the
files in the internal/compiler/widgets directory.
No extra manual steps were done.

Note: In order to run the updater, I did a hack so that the updater wouldn't
choke on internal item used by the styles by commenting out the check in
ElementType::lookup_type_for_child_element
2023-01-11 10:52:48 +01:00

38 lines
1.3 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
import { ScrollView } from "widget-scrollview.slint";
import { Item } from "widget-item.slint";
// `ListView` is like a `Scrollview` but it should have a for element, and the content are automatically layed out in a list.
export component ListView inherits ScrollView {
@children
}
component StandardListViewBase inherits ListView {
in property<[StandardListViewItem]> model;
in-out property<int> current-item: -1;
for item[idx] in root.model : Item {
selected: idx == root.current-item;
text: item.text;
clicked => { root.current-item = idx; }
}
}
// Like `ListView`, but with a default delegate, and a `model` property which is a model of type `StandardListViewItem`.
export component StandardListView inherits StandardListViewBase {
FocusScope {
key-pressed(event) => {
if (event.text == Key.UpArrow && root.current-item > 0) {
root.current-item -= 1;
return accept;
} else if (event.text == Key.DownArrow && root.current-item + 1 < root.model.length) {
root.current-item += 1;
return accept;
}
reject
}
}
}