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

Author Topic: Mouse isButtonReleased  (Read 5537 times)

0 Members and 1 Guest are viewing this topic.

Deadpool18

  • Newbie
  • *
  • Posts: 9
    • View Profile
Mouse isButtonReleased
« on: March 18, 2016, 11:54:31 pm »
I need to use the mouse to launch certain events and animation in my school project using SFML 2.3. In the sf::Mouse class documnentation you mention the MouseButtonReleased in this exact context :
"Compared to the MouseMoved, MouseButtonPressed and MouseButtonReleased events, sf::Mouse can retrieve the state of the cursor and the buttons at any time (you don't need to store and update a boolean on your side in order to know if a button is pressed or released), and you always get the real state of the mouse, even if it is moved, pressed or released when your window is out of focus and no event is triggered."

BUT there doesn't exist a method isButtonReleased like there is a isButtonPressed...... WHY ? I need that method !

bitano

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Mouse isButtonReleased
« Reply #1 on: March 19, 2016, 12:02:16 am »
There is an event sf::Event::MouseButtonReleased :-)

ka0s420

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
    • Email
Re: Mouse isButtonReleased
« Reply #2 on: March 19, 2016, 12:05:29 am »
you'll need to use the event queue for that. Think about it, it doesn't make sense to constantly check if mousebutton is released, released buttons are move like switches they can be on or off.  when you're not using an event queue and you press the mouse button, it registers more than one click, so every time you let go of the mouse button it would register several times. I cant think how that would be useful.

here's how to do it with an event queue:
sf::Event event;

        while (mWindow.pollEvent(event)) {

                switch (event.type)
                {
                case sf::Event::MouseButtonReleased:
                 //do something
         break;
 
« Last Edit: March 19, 2016, 12:08:10 am by ka0s420 »

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Mouse isButtonReleased
« Reply #3 on: March 19, 2016, 12:09:59 am »
If a button isn't pressed, it is released..

bitano

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Mouse isButtonReleased
« Reply #4 on: March 19, 2016, 12:10:40 am »
If a button isn't pressed, it is released..
...Or it wasn't pressed at all :P

 

anything