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

Author Topic: [SOLVED] Mouse isButtonPressed doesn't work  (Read 2683 times)

0 Members and 1 Guest are viewing this topic.

Dubmosphere

  • Newbie
  • *
  • Posts: 13
    • View Profile
[SOLVED] Mouse isButtonPressed doesn't work
« 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;
}
 
« Last Edit: January 28, 2015, 04:13:24 pm by Dubmosphere »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Mouse isButtonPressed doesn't work
« Reply #1 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?
« Last Edit: January 27, 2015, 12:00:19 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Dubmosphere

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: AW: Mouse isButtonPressed doesn't work
« Reply #2 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?
« Last Edit: January 27, 2015, 01:16:18 pm by Dubmosphere »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Mouse isButtonPressed doesn't work
« Reply #3 on: January 27, 2015, 01:16:51 pm »
Laurent Gomila - SFML developer

Dubmosphere

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Mouse isButtonPressed doesn't work
« Reply #4 on: January 27, 2015, 02:12:41 pm »
Thanks for the link,

I finally got it working with this.

 

anything