aboutsummaryrefslogtreecommitdiff
path: root/src/gui/RadioButton.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/RadioButton.cpp')
-rw-r--r--src/gui/RadioButton.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/gui/RadioButton.cpp b/src/gui/RadioButton.cpp
index 061d811..a6ef96a 100644
--- a/src/gui/RadioButton.cpp
+++ b/src/gui/RadioButton.cpp
@@ -35,12 +35,12 @@ namespace gsr {
const bool mouse_inside = mgl::FloatRect(draw_pos, item_size).contains(mgl::vec2f(event.mouse_button.x, event.mouse_button.y));
if(mouse_inside) {
- const size_t prev_selected_item = selected_item;
- selected_item = i;
-
- if(selected_item != prev_selected_item && on_selection_changed)
- on_selection_changed(item.text.get_string(), item.id);
+ if(selected_item != i && on_selection_changed) {
+ if(!on_selection_changed(item.text.get_string(), item.id))
+ return false;
+ }
+ selected_item = i;
return false;
}
@@ -158,12 +158,12 @@ namespace gsr {
for(size_t i = 0; i < items.size(); ++i) {
auto &item = items[i];
if(item.id == id) {
- const size_t prev_selected_item = selected_item;
- selected_item = i;
-
- if(trigger_event && (trigger_event_even_if_selection_not_changed || selected_item != prev_selected_item) && on_selection_changed)
- on_selection_changed(item.text.get_string(), item.id);
+ if(trigger_event && (trigger_event_even_if_selection_not_changed || selected_item != i) && on_selection_changed) {
+ if(!on_selection_changed(item.text.get_string(), item.id))
+ break;
+ }
+ selected_item = i;
break;
}
}