[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;
}
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();
}