how to reset all values in an array? #6659
Answered
by
ogoffart
TheColorRed
asked this question in
Q&A
-
I am looking to loop over any array and reset a setting back to here is some pseudo code (untested): export struct Example {
selected: bool
}
export component AppWindow inherits Window {
property <int> current: 1;
property <[Example]> items: [
{ selected: false; }
{ selected: false; }
{ selected: false; }
]
VerticalLayout {
for x in items: Rectangle {
background: items[current].selected ? #ffffff58 : #ffffff2e;
height: 100px;
ta := TouchArea {
clicked => {
for i in items { i.selected = false; } // Reset the values to false
items[current].selected = true;
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
ogoffart
Oct 26, 2024
Replies: 1 comment 1 reply
-
This is the kind of things that are part of the logic and which needs to be done in the programming language at the moment. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
TheColorRed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the kind of things that are part of the logic and which needs to be done in the programming language at the moment.
Add a callback to your AppWindow, and this callback can be set to iterate over the model and unselect everything.