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

Author Topic: If for mouse wheel scrolling  (Read 2059 times)

0 Members and 1 Guest are viewing this topic.

Munchor

  • Newbie
  • *
  • Posts: 16
    • View Profile
If for mouse wheel scrolling
« on: July 20, 2013, 01:14:36 pm »
I know I can use this event[1] to listen to a mouse wheel scroll event, but I'd rather use an "if" statement to listen to it like I can do with button events:

if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
{

}

Is there any way to do so? I tried to use isButtonPressed(sf::Mouse::Middle) but that listens to the scroll wheel button being down not it being scrolled (which is the right thing to listen to of course).

[1]: http://sfml-dev.org/documentation/2.0/structsf_1_1Event_1_1MouseWheelEvent.php

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: If for mouse wheel scrolling
« Reply #1 on: July 20, 2013, 01:18:48 pm »
No, because the mouse wheel has no state, you are only notified about changes.

What you can do is accumulate the total mouse wheel delta per frame, and use it in another if condition.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10823
    • View Profile
    • development blog
    • Email
AW: If for mouse wheel scrolling
« Reply #2 on: July 20, 2013, 01:19:55 pm »
There isn't but it's simple to poll the event and save the data, so you could do an if check against it later on.
There are also a few feature requests about getting the raw data from the scroll wheel.

Btw you can use BB codes to link certain texts instead of using footnotes. ;)
[ url=URL ]text[ /url ] (without spaces)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/