Yeah I already have that line included in another file along with the rest of the SFML window setup:
#include "Window.h"
sf::RenderWindow w(sf::VideoMode(1000, 700), "Window");
sf::Event e;
window_methods mw;
void window_methods::close_window() {
ImGui::SFML::ProcessEvent(e);
while (w.pollEvent(e)) {
switch (e.type) {
case sf::Event::Closed:
w.close();
break;
}
}
}
It's not that the code was in a seperate file as such, it's that:
ImGui::SFML::ProcessEvent(e);
while (w.pollEvent(e)) {
should have been:
while (w.pollEvent(e)) {
ImGui::SFML::ProcessEvent(e);
You were passing an event to Imgui before reading the event (pollEvent), so it just contained a leftover of the last event from the previous pass of the while loop. (So if a key event came through, every frame after that would see the same key event repeat until a different event wrote over it)