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

Author Topic: mac os mouse wheel delta  (Read 2473 times)

0 Members and 1 Guest are viewing this topic.

koyuki

  • Guest
mac os mouse wheel delta
« on: November 10, 2019, 10:56:48 pm »
hello everyone, i am trying to understand why the same code in Linux works fine, while on mac not.

the problem seams to be with mouse wheel delta.
if (event.type == sf::Event::MouseWheelMoved) {   //zoom
                zoomView(event.mouseWheel.delta);
                std::cout << event.mouseWheel.delta << '\n';
            }

and
void Game::zoomView(int zoom) {
    renderWindow.clear();

    if (zoom == 1)
        view.zoom(0.9);
    else
        view.zoom(1.05);
    renderWindow.clear();

    renderWindow.setView(view);
}

i added that cout to check the output, and it doesn't matter if i use a mouse or the pad of my macbook, if i  scroll up or down it will always print 0 causing a zoom out.
 well sometimes, if i scroll a lot harder, it prints different numbers and the zooming seams not to know if to scroll in or out, but the final effect is always to scroll down.

i need a solution to make it work in any situation.
i can't make it zoom in and/orout using keys.
thanks for your helping.
« Last Edit: November 10, 2019, 11:05:39 pm by koyuki »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: mac os mouse wheel delta
« Reply #1 on: November 11, 2019, 08:56:48 am »
The MouseWheelMoved event has been deprecated as it can lead to inaccuracies. Try the MouseWheelScroll event: https://www.sfml-dev.org/documentation/2.5.1/structsf_1_1Event_1_1MouseWheelScrollEvent.php
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything