From 00c637961bf06606fc5a1d8122e9bc74c65bb814 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 8 Feb 2019 14:50:36 +0100 Subject: [PATCH] Demo: Font selector allow selecting fonts with same debug name. (#2332) --- imgui_demo.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 796f7355d..2ce06d6c1 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -2738,8 +2738,13 @@ void ImGui::ShowFontSelector(const char* label) if (ImGui::BeginCombo(label, font_current->GetDebugName())) { for (int n = 0; n < io.Fonts->Fonts.Size; n++) - if (ImGui::Selectable(io.Fonts->Fonts[n]->GetDebugName(), io.Fonts->Fonts[n] == font_current)) - io.FontDefault = io.Fonts->Fonts[n]; + { + ImFont* font = io.Fonts->Fonts[n]; + ImGui::PushID((void*)font); + if (ImGui::Selectable(font->GetDebugName(), font == font_current)) + io.FontDefault = font; + ImGui::PopID(); + } ImGui::EndCombo(); } ImGui::SameLine();