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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - oni2180

Pages: [1]
1
Window / Re: Mouse wheel moved issue
« on: June 17, 2015, 08:31:22 pm »
Is it inside the event loop?
PS: if you're using SFML 2.3, use the MouseWheelScrolled event instead.
It is not inside the loop, thanks, such a newbie error !

When I get the if() off and just type :

std::cout << "wheel movement: " << event.mouseWheel.delta << "  " << event.mouseWheel.x << "  " << event.mouseWheel.y << std::endl;
You MUST check event.type before accessing any other member and then only access members that are actually valid for that type.

See also: A Guide to Undefined Behavior in C and C++
You are absolutely right, thank you

2
Window / Mouse wheel moved issue
« on: June 17, 2015, 07:55:43 pm »
Hello,
I have a problem with the MouseWheelMoved event but not only.
When I do this:

if(event.type == Event::MouseWheelMoved){
            std::cout << "wheel movement: " << event.mouseWheel.delta << "  " << event.mouseWheel.x << "  " << event.mouseWheel.y << std::endl;
        }

nothing happens when I turn the wheel (even very fast), so it does not enter the if().
When I get the if() off and just type :

std::cout << "wheel movement: " << event.mouseWheel.delta << "  " << event.mouseWheel.x << "  " << event.mouseWheel.y << std::endl;

I get several different data depending on the action. For the example, take x=125 and y=112. When just moving the mouse, I have the X value inside delta, the Y value inside the X and some very long number (looks like an adress) in the Y : 125  112  2002418353

If I click, I get the click value (0, 1 or 2 depending on the button) inside the delta and X and Y are normal : 1  125  112

Finally, when I rotate the wheel I have 0 in delta, some positive adress when up and negative when down in X, and X in Y : 0  106535816  125 when up and 0  -1082130432  125 when down.

Bonus : When offscreen : -21, then 0 and then an adress : -21  0  12089408.

Did I make a mistake inside the code? Is that normal? How should I access the good wheel numering?

Pages: [1]