Skip to content

ListView cannot focus #1718

Answered by ogoffart
Decodetalkers asked this question in Q&A
Oct 8, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

The StandardListView widget actually handle the up and down keys. Here is the implementation in case you want to do the same in your custom ListView:

export StandardListView := ListView {
property<[StandardListViewItem]> model;
property<int> current-item: -1;
for item[idx] in model : Rectangle {
l := HorizontalLayout {
padding: 8px;
spacing: 0px;
t := Text {
text: item.text;
color: Palette.neutralPrimary;
}
}
background: idx == root.current-item ? Palette.neutralLighter
: touch.has-hover ? Palette.neutralLighterAlt : transparent;

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Decodetalkers
Comment options

Answer selected by Decodetalkers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants