SFML community forums

Help => Window => Topic started by: Dubmosphere on January 27, 2015, 11:50:44 am

Title: [SOLVED] Mouse isButtonPressed doesn't work
Post by: Dubmosphere on January 27, 2015, 11:50:44 am
Hello, I'm creating a Mapeditor and now I need sf::Mouse::isButtonPressed(sf::Mouse::Button::Left). The Problem is, even when i press the left mousebutton, the method returns false. I don't know why this happens but it happens on the smallest example too. So it may be a bug in SFML or am I doing something wrong?

I compiled SFML 2.2 static on Linux with GCC 4.9.2 64bit, if this Information helps.

Thanks for your help.

Even on this small example it happens:
#include <iostream>
#include <SFML/Graphics.hpp>

int main(int argc, char **argv) {
    sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Example", sf::Style::Close);
    window.setFramerateLimit(60.f);

    while(window.isOpen()) {
        sf::Event event;
        while(window.pollEvent(event)) {
            switch(event.type) {
                case sf::Event::Closed:
                    window.close();
                    break;
                default:
                    break;
            }
        }

        if(sf::Mouse::isButtonPressed(sf::Mouse::Button::Left))
            std::cout << "Hello left button" << std::endl;

        window.clear();

        window.display();
    }

    return 0;
}
 
Title: AW: Mouse isButtonPressed doesn't work
Post by: eXpl0it3r on January 27, 2015, 11:57:57 am
When did you build SFML?
And did you use SFML 2.2 or the latest Git version?
Title: Re: AW: Mouse isButtonPressed doesn't work
Post by: Dubmosphere on January 27, 2015, 01:10:53 pm
I built it last week with the sources from git. But I downloaded it again today and built it again and the problem still exists.

Should I try it with the 2.2 Sources?
Title: Re: Mouse isButtonPressed doesn't work
Post by: Laurent on January 27, 2015, 01:16:51 pm
https://github.com/SFML/SFML/issues/786
Title: Re: Mouse isButtonPressed doesn't work
Post by: Dubmosphere on January 27, 2015, 02:12:41 pm
Thanks for the link,

I finally got it working with this.