SFML community forums

Help => System => Topic started by: HeinzK on September 09, 2014, 11:15:08 am

Title: MouseWheel ..
Post by: HeinzK on September 09, 2014, 11:15:08 am
deleted
Title: Re: MousWheel ..
Post by: Hiura on September 09, 2014, 11:31:02 am
can we see how you get the event (basically, the event switch)?
Title: Re: MousWheel ..
Post by: Hiura on September 09, 2014, 01:16:35 pm
You should read the tutorial again and learn how to use an union type.
Title: Re: MouseWheel ..
Post by: Hiura on September 09, 2014, 04:16:53 pm
a) what do you mean? I see no mouse move here. You get the position of the mouse when the wheel was actioned as well as the 'ticks'.

b) because it wouldn't make sense. (http://en.sfml-dev.org/forums/index.php?topic=5542.msg36276#msg36276)
Title: Re: MouseWheel ..
Post by: zsbzsb on September 09, 2014, 04:56:58 pm
a) .. 180 172 160 140 107 65 11 .. are mousemove in 'delta' (the wheel is not in use!) .. look at IMG.

Because....

You should read the tutorial again and learn how to use an union type.
Title: Re: MouseWheel ..
Post by: G. on September 09, 2014, 04:59:36 pm
event.mouseWheel.delta is the number of click the mouse wheel has scrolled. It's expressed in delta because the wheel has no state. It's basically "the mouse wheel has scrolled 2 times in the positive direction" if you get 2 or "the mouse wheel has scrolled 1 time in the negative position" if you get -1.
It is supposed to be used inside the event loop, only when the current event type is a MouseWheelMoved event (http://sfml-dev.org/tutorials/2.1/window-events.php#the-mousewheelmoved-event). If you're reading these values outside of this, it's wrong.
It is in no way related to the mouse position or mouse movement. However there are x and y in MouseWheelMoved event, to know where the mouse was when this mouse wheel event was triggered.

The code you posted is not real code and is weird, what's the point?
#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "...");
    while (window.isOpen()) {
        sf::Event event;
        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed) {
                window.close();
            }
            if (event.type == sf::Event::MouseWheelMoved) {
                std::cout << "wheel movement: " << event.mouseWheel.delta << std::endl;
                std::cout << "mouse x: " << event.mouseWheel.x << std::endl;
                std::cout << "mouse y: " << event.mouseWheel.y << std::endl;
            }
        }

        window.clear();
        window.display();
    }
    return 0;
}
It's hard to believe that with more than 80 posts and 2 years here you don't know how to properly use events, are you trolling?
Title: Re: MouseWheel ..
Post by: G. on September 09, 2014, 07:11:05 pm
It's hard to understand you. :p
Make SURE you only read mouse wheel event values inside the event loop when the event type is a mouse wheel event.