[nostalgia/gfx/studio/palette] Make page rename dialog accept on enter if input focused
All checks were successful
Build / build (push) Successful in 1m19s

This commit is contained in:
Gary Talent 2025-05-04 00:14:18 -05:00
parent b8d7658626
commit 640ac85de4

View File

@ -50,15 +50,18 @@ void PaletteEditorImGui::PageRenameDialog::draw(turbine::Context &tctx) noexcept
return; return;
} }
if (ig::BeginPopup(tctx, "Rename Page", m_show)) { if (ig::BeginPopup(tctx, "Rename Page", m_show)) {
if (ImGui::IsWindowAppearing()) {
ImGui::SetKeyboardFocusHere();
}
ig::InputText("Name", m_name); ig::InputText("Name", m_name);
switch (ig::PopupControlsOkCancel(m_show)) { auto const nameInputFocused = ImGui::IsItemFocused();
case ig::PopupResponse::OK: auto const resp = ig::PopupControlsOkCancel(m_show);
if ((nameInputFocused && ImGui::IsKeyPressed(ImGuiKey_Enter))
|| resp == ig::PopupResponse::OK) {
inputSubmitted.emit(m_name); inputSubmitted.emit(m_name);
[[fallthrough]];
case ig::PopupResponse::Cancel:
close(); close();
default: } else if (resp == ig::PopupResponse::Cancel) {
break; close();
} }
ImGui::EndPopup(); ImGui::EndPopup();
} }