Skip to content

Commit

Permalink
Fixed initial input focus for hidden menu.
Browse files Browse the repository at this point in the history
Issue #201
  • Loading branch information
k4zmu2a committed Jan 27, 2024
1 parent 75d2d98 commit 73262ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
2 changes: 1 addition & 1 deletion SpaceCadetPinball/pb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void pb::firsttime_setup()

void pb::mode_change(GameModes mode)
{
if (CreditsActive)
if (CreditsActive && MissTextBox)
MissTextBox->Clear(true);
CreditsActive = false;
IdleTimerMs = 0;
Expand Down
33 changes: 11 additions & 22 deletions SpaceCadetPinball/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,32 +436,21 @@ void winmain::MainLoop()

void winmain::RenderUi()
{
// A minimal window with a button to prevent menu lockout.
if (!Options.ShowMenu)
// Transparent menu bar with a button for preventing menu lockout.
ImGui::PushStyleColor(ImGuiCol_MenuBarBg, ImVec4{});
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4{});
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
if (!Options.ShowMenu && ImGui::BeginMainMenuBar())
{
ImGui::SetNextWindowPos(ImVec2{});
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{10, 0});
if (ImGui::Begin("main", nullptr,
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoBackground |
ImGuiWindowFlags_AlwaysAutoResize |
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoFocusOnAppearing))
if (ImGui::MenuItem("Menu"))
{
ImGui::PushID(1);
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{});
if (ImGui::Button("Menu"))
{
options::toggle(Menu1::Show_Menu);
}
ImGui::PopStyleColor(1);
ImGui::PopID();
}
ImGui::End();
ImGui::PopStyleVar();

// This window can not loose nav focus for some reason, clear it manually.
if (ImGui::IsKeyDown(ImGuiKey_Escape) || ImGui::IsKeyDown(ImGuiKey_GamepadFaceRight))
options::toggle(Menu1::Show_Menu);
ImGui::FocusWindow(nullptr);
}
ImGui::EndMainMenuBar();
}
ImGui::PopStyleVar(1);
ImGui::PopStyleColor(2);

// No demo window in release to save space
#ifndef NDEBUG
Expand Down

0 comments on commit 73262ae

Please sign in to comment.