From 3a20c417cbf7d5db1d9d26abfbda388e58f96c18 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 3 Aug 2024 23:36:11 +0200 Subject: Align list items, dont process selected item twice if changed in event loop, mouse button events should only occur when pressing left mouse button --- src/gui/ComboBox.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/gui/ComboBox.cpp') diff --git a/src/gui/ComboBox.cpp b/src/gui/ComboBox.cpp index 03e66bd..3aa4439 100644 --- a/src/gui/ComboBox.cpp +++ b/src/gui/ComboBox.cpp @@ -46,7 +46,6 @@ namespace gsr { set_widget_as_selected_in_parent(); else remove_widget_as_selected_in_parent(); - return false; } else { show_dropdown = false; remove_widget_as_selected_in_parent(); @@ -118,6 +117,15 @@ namespace gsr { dirty = true; } + void ComboBox::set_selected_item(const std::string &id) { + for(size_t i = 0; i < items.size(); ++i) { + if(items[i].id == id) { + selected_item = i; + break; + } + } + } + void ComboBox::update_if_dirty() { if(!dirty) return; -- cgit v1.2.3