Game Development Community

onMouseWheel?

by Kevin James · in Torque Game Builder · 08/06/2010 (2:28 pm) · 5 replies

How do I use the mouse wheel?

I don't see that callback here:
tdn.garagegames.com/wiki/TGB/Reference:_t2dSceneWindow

About the author

Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/


#1
08/06/2010 (2:38 pm)
I don't think there is a callback for it. Access it using a bindCmd.
actionMap.bindCmd(mouse, "zaxis", "doMouseWheelFunction", "");
#2
08/06/2010 (3:01 pm)
You are correct. I'm getting close with this:
moveMap.bind(mouse0, zaxis, zoomMap);

But I need to distinguish between wheel forward / wheel back

It only sees one of the functions:
moveMap.bind(mouse0, zaxis, zoomMapOut, zoomMapIn);

And the bind command does not accept parameters like bndCmd:

moveMap.bindCmd(keyboard, "up", "$player.PlayerUp(1);", "$player.PlayerUp(0);");
#3
08/06/2010 (3:21 pm)
Ok dude...

moveMap.bind(mouse0, zaxis, "doMouseWheelFunction");  

function doMouseWheelFunction(%val)
{
   echo("mouse wheel moved:" SPC %val);
   
   if(%val > 0)
   {
      echo("Mouse moved forward");  
   }
   else if(%val < 0)
   {
      echo("Mouse moved backard"); 
   }
}
#4
08/06/2010 (3:29 pm)
Crazy! I never would have guessed:

Mousewheel forward: %val = 120
Mousewheel backward: %val = -120

Thus, this works:
moveMap.bind(mouse0, zaxis, zoomWheel);
...

function zoomWheel(%val)
{
   zoomMap(%val>0);
}

Thanks Patrick!
#5
08/06/2010 (3:44 pm)
I was curious if that value was device specific but I get 120/-120 as well. You're welcome!