Skip to content

Commit 4727cf1

Browse files
committed
Update to new SFML event polling API
1 parent ee754ac commit 4727cf1

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ Using ImGui-SFML in your code
7373
- Poll and process events:
7474

7575
```cpp
76-
sf::Event event;
77-
while (window.pollEvent(event)) {
76+
while (const auto event = window.pollEvent()) {
7877
ImGui::SFML::ProcessEvent(window, event);
7978
...
8079
}
@@ -114,8 +113,7 @@ int main() {
114113

115114
sf::Clock deltaClock;
116115
while (window.isOpen()) {
117-
sf::Event event;
118-
while (window.pollEvent(event)) {
116+
while (const auto event = window.pollEvent()) {
119117
ImGui::SFML::ProcessEvent(window, event);
120118

121119
if (event.type == sf::Event::Closed) {

examples/minimal/main.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ int main() {
1414

1515
sf::Clock deltaClock;
1616
while (window.isOpen()) {
17-
sf::Event event{};
18-
while (window.pollEvent(event)) {
17+
while (const auto event = window.pollEvent()) {
1918
ImGui::SFML::ProcessEvent(window, event);
2019

2120
if (event.is<sf::Event::Closed>()) {

examples/multiple_windows/main.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ int main() {
1616
sf::Clock deltaClock;
1717
while (window.isOpen()) {
1818
// Main window event processing
19-
sf::Event event{};
20-
while (window.pollEvent(event)) {
19+
while (const auto event = window.pollEvent()) {
2120
ImGui::SFML::ProcessEvent(window, event);
2221
if (event.is<sf::Event::Closed>()) {
2322
if (childWindow.isOpen()) {
@@ -31,7 +30,7 @@ int main() {
3130

3231
// Child window event processing
3332
if (childWindow.isOpen()) {
34-
while (childWindow.pollEvent(event)) {
33+
while (const auto event = childWindow.pollEvent()) {
3534
ImGui::SFML::ProcessEvent(childWindow, event);
3635
if (event.is<sf::Event::Closed>()) {
3736
childWindow.close();

0 commit comments

Comments
 (0)