-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TreeNode problem #147
Comments
Hello. It would be also perfect if you try to run the code with other binding and be sure that it’s not an ImGui’s bug. Though it might be SFML or your program not catching "window activated/regained focus" |
Main loop: while(window->isOpen())
{
sf::Event event;
handleEvent(event);// ImGui::SFML::ProcessEvent(event);
ImGui::SFML::Update(*window, deltaClock.restart());
if(ImGui::Begin("Tools Window", NULL, window_flags))
{...}
update();
draw();// ImGui::SFML::Render(*window);
} How I use TreeNode: for(auto& group : groups)
{
ImGui::PushID(group_id);
node_open = ImGui::TreeNodeEx((void*) (intptr_t) group_id, nd, "%s", group->getName().c_str());
if(node_open)
{
for(auto& elem:group)
{
ImGui::PushID(elem_id);
ImGui::Text(...)
ImGui::PopID();
}
ImGui::TreePop();
}else{...}
ImGui::PopID();
} Absolutely all TreeNode stop working, even in TestWindow, which provides ImGui. I also don't handle the LostFocus and GainedFocus states in any way, could this be an error? while(window->isOpen())
{
sf::Event event;
handleEvent(event);// ImGui::SFML::ProcessEvent(event);
ImGui::SFML::Update(*window, deltaClock.restart());
if(ImGui::TreeNode("adsfjklhasdkufj"))
{
ImGui::Text("asdasd");
ImGui::TreePop();
}
draw();// ImGui::SFML::Render(*window);
} |
When I launch a window without focusing on it, absolutely all ImGui elements stop working. |
You don't need to handle it yourself, but SFML should send Gained/LostFocus events. Does it do it? Can you check it, please? Maybe it's the problem with your WM which SFML doesn't work correctly with. I think that ideally I should remove this Gained/Lost event processing stuff, but I'm afraid most people will get confused that ImGui elements would work even if your window is not in focus (e.g. if you click on the text box, you'll be able to write in it even if the window loses focus) |
Can you please remove all |
Completely removed |
Does it reproduce when you insert the TreeNode code in the minimal example? |
Yes, after minimizing the window, TreeNode do not open. |
Please try latest version of ImGui-SFML with ImGui 1.82 #include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>
#include "imgui-SFML.h"
#include "imgui.h"
int main() {
sf::RenderWindow window(sf::VideoMode(640, 480), "ImGui + SFML = <3");
window.setFramerateLimit(60);
ImGui::SFML::Init(window);
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
sf::Clock deltaClock;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
ImGui::SFML::ProcessEvent(event);
if (event.type == sf::Event::Closed) {
window.close();
}
}
ImGui::SFML::Update(window, deltaClock.restart());
ImGui::Begin("Hello, world!");
ImGui::Button("Look at this pretty button");
if (ImGui::TreeNode("adsfjklhasdkufj")) {
ImGui::Text("asdasd");
ImGui::TreePop();
}
ImGui::End();
ImGui::ShowDemoWindow();
window.clear();
window.draw(shape);
ImGui::SFML::Render(window);
window.display();
}
ImGui::SFML::Shutdown();
return 0;
} |
Personally, I still have a problem :). As I understand it, after minimizing the window (alt+tab), an event about the alt key being pressed comes from sfml, but the event that alt was released does not come. And imgui thinks that the alt key is pressed and the interface works differently, for example, treenode will open only when you click on the arrow. Maybe I have some problem with my system. |
Oh, so it looks like it's related #88... Okay, I see, I'll try to fix that one first. |
Okay, I can confirm that Alt+Tab breaks things. When the window is out of focus, SFML doesn't catch any key input events, so the only way to fix it is to poll keyboard events. |
Fixed. Should work now. The problem is described in the commit message. |
Faced with a strange problem. After I minimize my app window, the TreeNode will stop opening, although other elements (buttons, menu bar) continue to work.
Before I collapsed the window:
After:
The text was updated successfully, but these errors were encountered: