Limit the scope of event object

This commit is contained in:
Chris Thrasher 2022-06-06 22:48:48 -06:00 committed by Vittorio Romeo
parent 745bcb82ef
commit dbac180db5
18 changed files with 19 additions and 39 deletions

View File

@ -32,8 +32,7 @@ int main()
while (window.isOpen()) while (window.isOpen())
{ {
sf::Event event; for (sf::Event event; window.pollEvent(event);)
while (window.pollEvent(event))
{ {
if (event.type == sf::Event::Closed) if (event.type == sf::Event::Closed)
window.close(); window.close();

View File

@ -37,8 +37,7 @@ int main()
while (window.isOpen()) while (window.isOpen())
{ {
sf::Event event; for (sf::Event event; window.pollEvent(event);)
while (window.pollEvent(event))
{ {
if (event.type == sf::Event::Closed) if (event.type == sf::Event::Closed)
window.close(); window.close();

View File

@ -44,8 +44,7 @@
/// while (window.isOpen()) /// while (window.isOpen())
/// { /// {
/// // Process events /// // Process events
/// sf::Event event; /// for (sf::Event event; window.pollEvent(event);)
/// while (window.pollEvent(event))
/// { /// {
/// // Close window: exit /// // Close window: exit
/// if (event.type == sf::Event::Closed) /// if (event.type == sf::Event::Closed)

View File

@ -109,9 +109,7 @@ int main(int argc, char *argv[])
while (window.isOpen()) while (window.isOpen())
{ {
sf::Event event; for (sf::Event event; active ? window.pollEvent(event) : window.waitEvent(event);)
while (active ? window.pollEvent(event) : window.waitEvent(event))
{ {
switch (event.type) switch (event.type)
{ {

View File

@ -183,8 +183,7 @@ int main()
while (window.isOpen()) while (window.isOpen())
{ {
// Handle events // Handle events
sf::Event event; for (sf::Event event; window.pollEvent(event);)
while (window.pollEvent(event))
{ {
// Window closed or escape key pressed: exit // Window closed or escape key pressed: exit
if ((event.type == sf::Event::Closed) || if ((event.type == sf::Event::Closed) ||

View File

@ -165,8 +165,7 @@ int main()
while (window.isOpen()) while (window.isOpen())
{ {
// Handle events // Handle events
sf::Event event; for (sf::Event event; window.pollEvent(event);)
while (window.pollEvent(event))
{ {
// Window closed or escape key pressed: exit // Window closed or escape key pressed: exit
if ((event.type == sf::Event::Closed) || if ((event.type == sf::Event::Closed) ||

View File

@ -197,8 +197,7 @@ int main()
while (window.isOpen()) while (window.isOpen())
{ {
// Process events // Process events
sf::Event event; for (sf::Event event; window.pollEvent(event);)
while (window.pollEvent(event))
{ {
// Close window: exit // Close window: exit
if (event.type == sf::Event::Closed) if (event.type == sf::Event::Closed)

View File

@ -406,8 +406,7 @@ int main()
while (window.isOpen()) while (window.isOpen())
{ {
// Process events // Process events
sf::Event event; for (sf::Event event; window.pollEvent(event);)
while (window.pollEvent(event))
{ {
// Close window: exit // Close window: exit
if (event.type == sf::Event::Closed) if (event.type == sf::Event::Closed)

View File

@ -111,8 +111,7 @@ int main()
while (window.isOpen()) while (window.isOpen())
{ {
// Handle events // Handle events
sf::Event event; for (sf::Event event; window.pollEvent(event);)
while (window.pollEvent(event))
{ {
// Window closed or escape key pressed: exit // Window closed or escape key pressed: exit
if ((event.type == sf::Event::Closed) || if ((event.type == sf::Event::Closed) ||

View File

@ -2463,8 +2463,7 @@ public:
while (window.isOpen()) while (window.isOpen())
{ {
// Process events // Process events
sf::Event event; for (sf::Event event; window.pollEvent(event);)
while (window.pollEvent(event))
{ {
// Close window: exit // Close window: exit
if (event.type == sf::Event::Closed) if (event.type == sf::Event::Closed)

View File

@ -136,8 +136,7 @@ int main()
while (window.isOpen()) while (window.isOpen())
{ {
// Process events // Process events
sf::Event event; for (sf::Event event; window.pollEvent(event);)
while (window.pollEvent(event))
{ {
// Close window: exit // Close window: exit
if (event.type == sf::Event::Closed) if (event.type == sf::Event::Closed)

View File

@ -203,8 +203,7 @@ private:
/// while (window.isOpen()) /// while (window.isOpen())
/// { /// {
/// // Event processing /// // Event processing
/// sf::Event event; /// for (sf::Event event; window.pollEvent(event);)
/// while (window.pollEvent(event))
/// { /// {
/// // Request for closing the window /// // Request for closing the window
/// if (event.type == sf::Event::Closed) /// if (event.type == sf::Event::Closed)

View File

@ -97,8 +97,7 @@ public:
/// sf::String string = sf::Clipboard::getString(); /// sf::String string = sf::Clipboard::getString();
/// ///
/// // or use it in the event loop /// // or use it in the event loop
/// sf::Event event; /// for (sf::Event event; window.pollEvent(event);)
/// while(window.pollEvent(event))
/// { /// {
/// if(event.type == sf::Event::Closed) /// if(event.type == sf::Event::Closed)
/// window.close(); /// window.close();

View File

@ -246,8 +246,7 @@ public:
/// ///
/// Usage example: /// Usage example:
/// \code /// \code
/// sf::Event event; /// for (sf::Event event; window.pollEvent(event);)
/// while (window.pollEvent(event))
/// { /// {
/// // Request for closing the window /// // Request for closing the window
/// if (event.type == sf::Event::Closed) /// if (event.type == sf::Event::Closed)

View File

@ -336,8 +336,7 @@ private:
/// while (window.isOpen()) /// while (window.isOpen())
/// { /// {
/// // Event processing /// // Event processing
/// sf::Event event; /// for (sf::Event event; window.pollEvent(event);)
/// while (window.pollEvent(event))
/// { /// {
/// // Request for closing the window /// // Request for closing the window
/// if (event.type == sf::Event::Closed) /// if (event.type == sf::Event::Closed)

View File

@ -165,8 +165,7 @@ public:
/// thus you should always call this function in a loop /// thus you should always call this function in a loop
/// to make sure that you process every pending event. /// to make sure that you process every pending event.
/// \code /// \code
/// sf::Event event; /// for (sf::Event event; window.pollEvent(event);)
/// while (window.pollEvent(event))
/// { /// {
/// // process event... /// // process event...
/// } /// }
@ -514,8 +513,7 @@ private:
/// while (window.isOpen()) /// while (window.isOpen())
/// { /// {
/// // Event processing /// // Event processing
/// sf::Event event; /// for (sf::Event event; window.pollEvent(event);)
/// while (window.pollEvent(event))
/// { /// {
/// // Request for closing the window /// // Request for closing the window
/// if (event.type == sf::Event::Closed) /// if (event.type == sf::Event::Closed)

View File

@ -60,8 +60,7 @@ int main(int, char const**)
while (window.isOpen()) while (window.isOpen())
{ {
// Process events // Process events
sf::Event event; for (sf::Event event; window.pollEvent(event);)
while (window.pollEvent(event))
{ {
// Close window: exit // Close window: exit
if (event.type == sf::Event::Closed) { if (event.type == sf::Event::Closed) {

View File

@ -58,8 +58,7 @@ int main(int argc, char const** argv)
while (window.isOpen()) while (window.isOpen())
{ {
// Process events // Process events
sf::Event event; for (sf::Event event; window.pollEvent(event);)
while (window.pollEvent(event))
{ {
// Close window: exit // Close window: exit
if (event.type == sf::Event::Closed) { if (event.type == sf::Event::Closed) {