Mousewheel scrolling?[SDL 2.03]

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Mousewheel scrolling?[SDL 2.03]

theatron
I've been experimenting with the mouse events today and im basically confused on how i can make this work the way i want it to. Whenever i scroll the mouse wheel up it literally only outputs the number 1. But when i trace tge mouses position it gives me alot more than just "1". Im trying to add a feature in my app that'll allow it to scroll up and down and how fast it'll scroll is based on how fast the wheels going(ex: Web Browsers).

Heres the code i had:







Code:

int y = 0;

void Update()
{
    if(evt.type = SDL_MOUSEWHEEL)
       {
                cout << y << endl;
        }

}


Is SDL 2 capable of the kind of mouse scrolling i mentioned? or am i doing it the wrong way :/ ?

Thanks

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: Mousewheel scrolling?[SDL 2.03]

Faluk
The mouse wheel even has the up and down information. If you have a event receiver function and an update function. Trough the event function you can get if the mouse moved up or down and the update function you can get the last wheel state and reset it. In this way you can get the direction for every loop. If the wheel move faster you will be able to get a value different than 0 in more loops.

Take a look to this tutorial, may be helpful.

http://www.falukdevelop.com/2016/09/07/sdl2_mouse_implementation/

Greetings!

2016-10-17 7:27 GMT+02:00 theatron <[hidden email]>:
I've been experimenting with the mouse events today and im basically confused on how i can make this work the way i want it to. Whenever i scroll the mouse wheel up it literally only outputs the number 1. But when i trace tge mouses position it gives me alot more than just "1". Im trying to add a feature in my app that'll allow it to scroll up and down and how fast it'll scroll is based on how fast the wheels going(ex: Web Browsers).

Heres the code i had:



Code:


int y = 0;

void Update()
{
    if(evt.type = SDL_MOUSEWHEEL)
       {
                cout << y << endl;
        }

}




Is SDL 2 capable of the kind of mouse scrolling i mentioned? or am i doing it the wrong way :/ ?

Thanks

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: Mousewheel scrolling?[SDL 2.03]

sanette-linux
In reply to this post by theatron

1. the basic behaviour is to add some fixed number of pixels to the
vertical position of the element you want to scroll at each mouse
wheel event.  for instance add (5 multiplied by the y field of
SDL_MouseWheelEvent)

2. if your event loop is not continuous or too slow, the events will
accumulate. It's a good idea to sum them up at once (and remove them
from the event queue).

3. if you want *smooth* scrolling like in most browsers, it is much more
delicate. Few people have a good code for this.



Le 17/10/2016 à 07:27, theatron a écrit :
> I've been experimenting with the mouse events today and im basically confused on how i can make this work the way i want it to. Whenever i scroll the mouse wheel up it literally only outputs the number 1. But when i trace tge mouses position it gives me alot more than just "1". Im trying to add a feature in my app that'll allow it to scroll up and down and how fast it'll scroll is based on how fast the wheels going(ex: Web Browsers). > > Heres the code i had: > > > > > > > > Code: > > int y = 0; > > void Update() > { >     if(evt.type = SDL_MOUSEWHEEL) >        { >                 cout << y << endl; >         } > > } > > > Is SDL 2 capable of the kind of mouse scrolling i mentioned? or am i doing it the wrong way :/ ? > > Thanks > > > _______________________________________________ > SDL mailing list > [hidden email] > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: Mousewheel scrolling?[SDL 2.03]

christosnc
This post has NOT been accepted by the mailing list yet.
Hello,

Could you please give more information on "3"?
It's fairly easy to implement a "working" solution just by setting every item's
y += mouseWheel_Y * someNumber

The real challenge is to get it smooth (like browsers).
Can you provide some examples - code - algorithm, anything to help us out?


With regards,
Christos Christou