Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Mouse wheel in allegro

This thread is locked; no one can reply to it. rss feed Print
Mouse wheel in allegro
CursedTyrant
Member #7,080
April 2006
avatar

Is there a way (or rather, a specific function), that would let me use the mouse wheel in my program (And detect if it's been "scrolled")? I'm coding a scrollable list of elements, and it would be nice if I could scroll it using said wheel.

---------
Signature.
----
[My Website] | [My YouTube Channel]

Thomas Fjellstrom
Member #476
June 2000
avatar

mouse_z is your friend.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

SonShadowCat
Member #1,548
September 2001
avatar

Check out mouse_z, I believe that deals with the wheel. http://allegro.cc/manual/api/mouse-routines/

Edit: 2 seconds late!

HoHo
Member #4,534
April 2004
avatar

There is a variable called mouse_z thats value changes when wheel is scrolled.

[edit]
Three minutes late because I thought there was some kind of longer explanation about it in manual but seems there isn't

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

CursedTyrant
Member #7,080
April 2006
avatar

Oh well, it would be much more readable if it would be called mouse_wheel, but I guess it'll have to do. One other thing, is there something like get_mouse_mickeys() which returns the wheel movement, or do I have to code it myself (I'm lazy, I know :P)?

---------
Signature.
----
[My Website] | [My YouTube Channel]

ixilom
Member #7,167
April 2006
avatar

Maybe something like this

void get_mouse_mickeys_ex(int *mickeyx, int *mickeyy, int *mickeyz)
{
  get_mouse_mickeys(mickeyx,mickeyy);
  static int mz = mouse_z;
  if(mouse_z != mz)
    *mickeyz = mouse_z - mz;
  else
    *mickeyz = 0;
  mz = mouse_z;
}

Havent tested it, probably not thinking straight either because I just woke up, use it at your own risk ;D

___________________________________________
Democracy in Sweden? Not since 2008-Jun-18.
<someone> The lesbians next door bought me a rolex for my birthday.
<someone> I think they misunderstood when I said I wanna watch...

Go to: