From 6cd52c82b5c8edd9c21404b8eeaf2ac43c0552c8 Mon Sep 17 00:00:00 2001 From: Florian Bruggisser Date: Fri, 6 Oct 2023 21:52:34 +0200 Subject: [PATCH] removed was-open check for combobox (#6178) Co-authored-by: Rene Sepulveda --- cpp/open3d/visualization/gui/Combobox.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cpp/open3d/visualization/gui/Combobox.cpp b/cpp/open3d/visualization/gui/Combobox.cpp index 9db8a2f7159..2bba54cc0f5 100644 --- a/cpp/open3d/visualization/gui/Combobox.cpp +++ b/cpp/open3d/visualization/gui/Combobox.cpp @@ -147,8 +147,6 @@ Size Combobox::CalcPreferredSize(const LayoutContext& context, Combobox::DrawResult Combobox::Draw(const DrawContext& context) { bool value_changed = false; - bool was_open = ImGui::IsPopupOpen(impl_->imgui_id_.c_str()); - bool did_open = false; auto& frame = GetFrame(); ImGui::SetCursorScreenPos( @@ -166,10 +164,8 @@ Combobox::DrawResult Combobox::Draw(const DrawContext& context) { DrawImGuiPushEnabledState(); ImGui::PushItemWidth(float(frame.width)); + if (ImGui::BeginCombo(impl_->imgui_id_.c_str(), GetSelectedValue())) { - if (!was_open) { - did_open = true; - } for (size_t i = 0; i < impl_->items_.size(); ++i) { bool isSelected = false; if (ImGui::Selectable(impl_->items_[i].c_str(), &isSelected, 0)) { @@ -185,13 +181,14 @@ Combobox::DrawResult Combobox::Draw(const DrawContext& context) { } ImGui::EndCombo(); } + ImGui::PopItemWidth(); DrawImGuiPopEnabledState(); ImGui::PopStyleColor(3); - return ((value_changed || did_open) ? Widget::DrawResult::REDRAW - : Widget::DrawResult::NONE); + return value_changed ? Widget::DrawResult::REDRAW + : Widget::DrawResult::NONE; } } // namespace gui