mirror of
https://github.com/ocornut/imgui.git
synced 2026-05-20 20:47:03 +08:00
Demo: ShowStyleSelector(), ShowFontSelector(): remove ImGuiSelectableFlags_NoAutoClosePopups for now.
build / Windows (push) Has been cancelled
build / Linux (push) Has been cancelled
build / MacOS (push) Has been cancelled
build / iOS (push) Has been cancelled
build / Emscripten (push) Has been cancelled
build / Android (push) Has been cancelled
scheduled / scheduled (push) Has been cancelled
build / Windows (push) Has been cancelled
build / Linux (push) Has been cancelled
build / MacOS (push) Has been cancelled
build / iOS (push) Has been cancelled
build / Emscripten (push) Has been cancelled
build / Android (push) Has been cancelled
scheduled / scheduled (push) Has been cancelled
In this situation we kinda want keyboard Enter to select and close but ideally not click. We don't have separate options yet.
This commit is contained in:
@@ -17875,7 +17875,7 @@ void ImGui::ShowFontSelector(const char* label)
|
||||
for (ImFont* font : io.Fonts->Fonts)
|
||||
{
|
||||
PushID((void*)font);
|
||||
if (Selectable(font->GetDebugName(), font == font_current, ImGuiSelectableFlags_SelectOnNav | ImGuiSelectableFlags_NoAutoClosePopups))
|
||||
if (Selectable(font->GetDebugName(), font == font_current, ImGuiSelectableFlags_SelectOnNav))
|
||||
io.FontDefault = font;
|
||||
if (font == font_current)
|
||||
SetItemDefaultFocus();
|
||||
|
||||
+7
-3
@@ -8224,17 +8224,18 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options.
|
||||
// Here we use the simplified Combo() api that packs items into a single literal string.
|
||||
// Useful for quick combo boxes where the choices are known locally.
|
||||
bool ImGui::ShowStyleSelector(const char* label)
|
||||
{
|
||||
// FIXME: This is a bit tricky to get right as style are functions, they don't register a name nor the fact that one is active.
|
||||
// So we keep track of last active one among our limited selection.
|
||||
static int style_idx = -1;
|
||||
const char* style_names[] = { "Dark", "Light", "Classic" };
|
||||
bool ret = false;
|
||||
if (ImGui::BeginCombo(label, (style_idx >= 0 && style_idx < IM_ARRAYSIZE(style_names)) ? style_names[style_idx] : ""))
|
||||
{
|
||||
for (int n = 0; n < IM_ARRAYSIZE(style_names); n++)
|
||||
if (ImGui::Selectable(style_names[n], style_idx == n, ImGuiSelectableFlags_SelectOnNav | ImGuiSelectableFlags_NoAutoClosePopups))
|
||||
{
|
||||
if (ImGui::Selectable(style_names[n], style_idx == n, ImGuiSelectableFlags_SelectOnNav))
|
||||
{
|
||||
style_idx = n;
|
||||
ret = true;
|
||||
@@ -8245,6 +8246,9 @@ bool ImGui::ShowStyleSelector(const char* label)
|
||||
case 2: ImGui::StyleColorsClassic(); break;
|
||||
}
|
||||
}
|
||||
else if (style_idx == n)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user