diff options
Diffstat (limited to 'src/gui/RadioButton.cpp')
-rw-r--r-- | src/gui/RadioButton.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gui/RadioButton.cpp b/src/gui/RadioButton.cpp index b3e9a4e..15b0989 100644 --- a/src/gui/RadioButton.cpp +++ b/src/gui/RadioButton.cpp @@ -121,10 +121,16 @@ namespace gsr { dirty = true; } - void RadioButton::set_selected_item(const std::string &id) { + void RadioButton::set_selected_item(const std::string &id, bool trigger_event) { for(size_t i = 0; i < items.size(); ++i) { - if(items[i].id == id) { + auto &item = items[i]; + if(item.id == id) { + const size_t prev_selected_item = selected_item; selected_item = i; + + if(trigger_event && selected_item != prev_selected_item && on_selection_changed) + on_selection_changed(item.text.get_string(), item.id); + break; } } |