Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed was-open check for ComboBox to fix freeze on macOS #6178

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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