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

Author Topic: Mouse wheel scroll detection still not working  (Read 3923 times)

0 Members and 1 Guest are viewing this topic.

KokosNaPalmie

  • Newbie
  • *
  • Posts: 10
    • View Profile
Mouse wheel scroll detection still not working
« on: March 14, 2020, 08:20:58 pm »
I'm trying to make settings state for my game and my mouse scroll detection is not working. I tried to find solution on sfml website, youtube and forums, even this one, but the only answer I got was
"Flush your cout buffer if you want it to print something. << std::endl or << std::flush", and the post is now far away from interest
Here's the function I made to move a view:
void Options::CheckEvents()
{
    if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))   // quit check
        this->quit = true;

    while(window->pollEvent(this->evnt))
    {
        if (this->evnt.type == sf::Event::MouseWheelScrolled)
        {
            std::cout << "[DEBUG]: mouse wheel scrolled\n"; // this one prints, but not always
                                                            // (for example 4 prints per 10s of scrolling)

            if (evnt.mouseWheelScroll.delta < 0 && view->getCenter().y > WinHeight / 2) // if view center is not too far away
            {
                std::cout << "[DEBUG]: View moved up\n"; // not printing, even when I remove this ^ check
                view->move(sf::Vector2f(0, -view_speed * this->dt));
            }
            if (evnt.mouseWheelScroll.delta > 0 && view->getCenter().y < WinHeight * 2) // if view center is not too far away
            {
                std::cout << "[DEBUG]: View moved down\n"; // not printing, even when I remove this ^ check
                view->move(sf::Vector2f(0,  view_speed * this->dt));
            }
        }
    }
}

And for good news, this code works in main class

KokosNaPalmie

  • Newbie
  • *
  • Posts: 10
    • View Profile

 

anything