From 640ac85de4e65c3566ba92750f6730eec96b450b Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 4 May 2025 00:14:18 -0500 Subject: [PATCH] [nostalgia/gfx/studio/palette] Make page rename dialog accept on enter if input focused --- .../paletteeditor/paletteeditor-imgui.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/nostalgia/modules/gfx/src/studio/paletteeditor/paletteeditor-imgui.cpp b/src/nostalgia/modules/gfx/src/studio/paletteeditor/paletteeditor-imgui.cpp index 06cca318..a0c24ab3 100644 --- a/src/nostalgia/modules/gfx/src/studio/paletteeditor/paletteeditor-imgui.cpp +++ b/src/nostalgia/modules/gfx/src/studio/paletteeditor/paletteeditor-imgui.cpp @@ -50,15 +50,18 @@ void PaletteEditorImGui::PageRenameDialog::draw(turbine::Context &tctx) noexcept return; } if (ig::BeginPopup(tctx, "Rename Page", m_show)) { + if (ImGui::IsWindowAppearing()) { + ImGui::SetKeyboardFocusHere(); + } ig::InputText("Name", m_name); - switch (ig::PopupControlsOkCancel(m_show)) { - case ig::PopupResponse::OK: - inputSubmitted.emit(m_name); - [[fallthrough]]; - case ig::PopupResponse::Cancel: - close(); - default: - break; + auto const nameInputFocused = ImGui::IsItemFocused(); + auto const resp = ig::PopupControlsOkCancel(m_show); + if ((nameInputFocused && ImGui::IsKeyPressed(ImGuiKey_Enter)) + || resp == ig::PopupResponse::OK) { + inputSubmitted.emit(m_name); + close(); + } else if (resp == ig::PopupResponse::Cancel) { + close(); } ImGui::EndPopup(); }