Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Circlify

Pages: [1]
1
Window / sf::Event::MouseButtonReleased fires twice
« on: April 12, 2022, 07:32:29 pm »
Hello! I noticed that, for whatever reason, sf::Event::MouseButtonReleased was firing twice (once when a mouse button was pressed and once when it was released). Why is this happening? I have shortened my code to this small snippet that causes the issue:

#include <iostream>
#include <SFML/Graphics.hpp>

int main() {
        sf::RenderWindow win(sf::VideoMode(800, 800), "window");

        while (win.isOpen()) {
                sf::Event e;
                while (win.pollEvent(e)) {
                        switch (e.type) {
                        case sf::Event::Closed:
                                win.close();
                        case sf::Event::MouseButtonPressed:
                                std::cout << "mouse button pressed\n";
                        case sf::Event::MouseButtonReleased:
                                std::cout << "mouse button released\n";
                        }
                }
                win.clear();
                win.display();

               
        }
}

Pages: [1]
anything