How to execute an action on value change #1501
-
Hello, so I have a setting page that has theme option. I'd like to execute an action if the value got changed. I could store the value in local variable and check if it's changed but I wonder if there is an api for that. My code ComboBox::from_id_source("theme")
.width(125.)
.selected_text(self.state.mode.as_ref())
.show_ui(ui, |ui| {
for option in Mode::iter().collect::<Vec<_>>() {
ui.selectable_value(&mut self.state.mode, option, option.as_ref());
}
}); |
Beta Was this translation helpful? Give feedback.
Answered by
coderedart
Apr 15, 2022
Replies: 1 comment 1 reply
-
you can simply check that the value in |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
kkharji
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can simply check that the value in
self.state.mode
has changed before and after running the UI code.also
ui.selectable_value()
returns aResponse
which has a.changed()
method which will return true if the value changed.