Skip to content

Commit

Permalink
Update to new SFML event polling API
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisThrasher committed May 28, 2024
1 parent 8d141e7 commit c8ebe8d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ Using ImGui-SFML in your code
- Poll and process events:

```cpp
sf::Event event;
while (window.pollEvent(event)) {
while (const auto event = window.pollEvent()) {
ImGui::SFML::ProcessEvent(window, event);
...
}
Expand Down Expand Up @@ -114,8 +113,7 @@ int main() {

sf::Clock deltaClock;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
while (const auto event = window.pollEvent()) {
ImGui::SFML::ProcessEvent(window, event);

if (event.type == sf::Event::Closed) {
Expand Down
3 changes: 1 addition & 2 deletions examples/minimal/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ int main() {

sf::Clock deltaClock;
while (window.isOpen()) {
sf::Event event{};
while (window.pollEvent(event)) {
while (const auto event = window.pollEvent()) {
ImGui::SFML::ProcessEvent(window, event);

if (event.is<sf::Event::Closed>()) {
Expand Down
5 changes: 2 additions & 3 deletions examples/multiple_windows/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ int main() {
sf::Clock deltaClock;
while (window.isOpen()) {
// Main window event processing
sf::Event event{};
while (window.pollEvent(event)) {
while (const auto event = window.pollEvent()) {
ImGui::SFML::ProcessEvent(window, event);
if (event.is<sf::Event::Closed>()) {
if (childWindow.isOpen()) {
Expand All @@ -31,7 +30,7 @@ int main() {

// Child window event processing
if (childWindow.isOpen()) {
while (childWindow.pollEvent(event)) {
while (const auto event = childWindow.pollEvent()) {
ImGui::SFML::ProcessEvent(childWindow, event);
if (event.is<sf::Event::Closed>()) {
childWindow.close();
Expand Down

0 comments on commit c8ebe8d

Please sign in to comment.