Skip to content

Commit

Permalink
removed was-open check for combobox (#6178)
Browse files Browse the repository at this point in the history
Co-authored-by: Rene Sepulveda <errissa@gmail.com>
  • Loading branch information
cansik and errissa authored Oct 6, 2023
1 parent ea2001f commit 6cd52c8
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions cpp/open3d/visualization/gui/Combobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)) {
Expand All @@ -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
Expand Down

0 comments on commit 6cd52c8

Please sign in to comment.