file not loading until clicked a second time
Noahwealsey opened this issue · comments
i am working on a music player and i am using this library for navigation and as soon as i select a file the dialog file closes and the file does not load but when i open the file dialog again, it works
Here's my code snippet:
`void Window::Update() {
ImGui::SFML::Update(m_window, deltaClock.restart());
if (ImGui::Begin("FILE EXPLORER"))
{
if (ImGui::Button("Select Directory"))
m_browser.Open();
}
ImGui::End();
static float volume = 100;
static bool pause = false;
ImGui::Begin("Volume Manager");
ImGui::SliderFloat("vol", &volume, 0, 100);
ImGui::End();
ImGui::Begin("play manager");
ImGui::Checkbox("Pause", &pause);
ImGui:: End();
m_browser.Display();
if (m_browser.HasSelected())
{
if (!fileSelected)
{
filePath = m_browser.GetSelected().string();
std::cout << filePath << "selected" << std::endl;
player.load(filePath);
player.play(volume);
player.pause(pause);
fileSelected = true;
}
else {
fileSelected = false;
}
}
}`
the volume and pause only works when the file dialog closes the first time, not while the music is running
m_browser is of type ImGui::FIleBrowser
and yes i double click to selecta file`
i did it i put the the file selected and m_browser.HasSelected() on the same if statement using and operator it worked but i can't change the files whille one is being played
Try adding m_browser.ClearSelected()
after GetSelected