diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 6213bdfde..2f96b8977 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -4840,6 +4840,7 @@ bool FurnaceGUI::loop() { } if (displayNew) { + newSongQuery = ""; displayNew=false; ImGui::OpenPopup("New Song"); } diff --git a/src/gui/newSong.cpp b/src/gui/newSong.cpp index 8fdafeb9b..081554121 100644 --- a/src/gui/newSong.cpp +++ b/src/gui/newSong.cpp @@ -23,6 +23,9 @@ #include void FurnaceGUI::drawNewSong() { + // Be sure to reset this to true when the popup is closed + static bool firstFrame = true; + bool accepted=false; ImGui::PushFont(bigFont); @@ -34,6 +37,10 @@ void FurnaceGUI::drawNewSong() { avail.y-=ImGui::GetFrameHeightWithSpacing(); if (ImGui::BeginChild("sysPickerC",avail,false,ImGuiWindowFlags_NoScrollWithMouse|ImGuiWindowFlags_NoScrollbar)) { + if (firstFrame) { + ImGui::SetKeyboardFocusHere(); + firstFrame = false; + } ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); if (ImGui::InputTextWithHint("##SysSearch","Search...",&newSongQuery)) { String lowerCase=newSongQuery; @@ -122,10 +129,12 @@ void FurnaceGUI::drawNewSong() { if (ImGui::Button("I'm feeling lucky")) { if (sysCategories.size()==0) { + firstFrame = true; ImGui::CloseCurrentPopup(); } else { FurnaceGUISysCategory* newSystemCat=&sysCategories[rand()%sysCategories.size()]; if (newSystemCat->systems.size()==0) { + firstFrame = true; ImGui::CloseCurrentPopup(); } else { unsigned int selection=rand()%newSystemCat->systems.size(); @@ -139,6 +148,7 @@ void FurnaceGUI::drawNewSong() { ImGui::SameLine(); if (ImGui::Button("Cancel")) { + firstFrame = true; ImGui::CloseCurrentPopup(); } @@ -157,6 +167,7 @@ void FurnaceGUI::drawNewSong() { selEnd=SelectionPoint(); cursor=SelectionPoint(); updateWindowTitle(); + firstFrame = true; ImGui::CloseCurrentPopup(); } }