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

Author Topic: MouseButtonReleased Event is spamming when moving the mouse  (Read 2531 times)

0 Members and 1 Guest are viewing this topic.

Asurael

  • Newbie
  • *
  • Posts: 3
    • View Profile
MouseButtonReleased Event is spamming when moving the mouse
« on: February 21, 2016, 02:39:43 pm »
Hello guys,

my problem is that the mousebuttonreleased event does not work for me. Here is the code for my event loop
void Framework::events()
{
        while (mWindow->pollEvent(*mEvent))
        {
        switch (mEvent->type)
        {
            case sf::Event::MouseButtonReleased:
            {
                std::cout << "Test";

            } break;

            default:
                break;
        }
        }
}

When i start my program test gets spammed when i move the mouse but the funny thing is that when i release my left or right mouse button nothing happens. What am I doing wrong?

The events function is in my game loop here is the code for it
void Framework::run()
{
        while (mWindow->isOpen())
        {
        events();
        update();
                render();
        }
}
 


DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: MouseButtonReleased Event is spamming when moving the mouse
« Reply #1 on: February 22, 2016, 03:29:14 am »
Hello guys,

my problem is that the mousebuttonreleased event does not work for me. Here is the code for my event loop
void Framework::events()
{
        while (mWindow->pollEvent(*mEvent))
        {
        switch (mEvent->type)
        {
            case sf::Event::MouseButtonReleased:
            {
                std::cout << "Test";
                break ; // SHOULD BE HERE!!
            }// break; // NOT HERE!!!

            default:
                break;
        }
        }
}



For switch you don't necessary need to use brackets {} :

void Framework::events()
{
        while (mWindow->pollEvent(*mEvent))
        {
        switch (mEvent->type)
        {
            case sf::Event::MouseButtonReleased: // This is OK. :)
                    std::cout << "Test";
                    break ;

            default:
                break;
        }
        }
}
« Last Edit: February 22, 2016, 03:40:05 am by DarkRoku »
I would like a spanish/latin community...
Problems building for Android? Look here

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: MouseButtonReleased Event is spamming when moving the mouse
« Reply #2 on: February 22, 2016, 09:22:15 am »
Quote
                break ; // SHOULD BE HERE!!
            }// break; // NOT HERE!!!
Makes absolutely no difference.
Laurent Gomila - SFML developer

Asurael

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: MouseButtonReleased Event is spamming when moving the mouse
« Reply #3 on: February 22, 2016, 04:03:05 pm »
Does no one knows whats the problem with my code? :(

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: MouseButtonReleased Event is spamming when moving the mouse
« Reply #4 on: February 23, 2016, 12:10:25 am »
Create a minimal and complete example, e.g. just the standard game loop + event loop.

If the issue persists then my guess would be that you use outdated SFML header files, i.e. you updated the library files but didn't update the header files (or the other way around).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Asurael

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: MouseButtonReleased Event is spamming when moving the mouse
« Reply #5 on: February 23, 2016, 02:41:58 pm »
Quote
If the issue persists then my guess would be that you use outdated SFML header files, i.e. you updated the library files but didn't update the header files (or the other way around).

That was the problem! Thank you very much!!

Jabberwocky

  • Full Member
  • ***
  • Posts: 157
    • View Profile
Re: MouseButtonReleased Event is spamming when moving the mouse
« Reply #6 on: February 23, 2016, 04:58:55 pm »
Pretty slick guru debugging, eXpl0it3r. 

 

anything