beo6 Posted January 24, 2014 Share Posted January 24, 2014 Hello, i have a small problem to recognize if i moved the mousewheel up or down. i get the mouse z value by: local mouseWheelPos = window:GetMousePosition().z System:Print("Mouse wheel: "..mouseWheelPos) but i noticed that the value i get out of it always goes up. Only when a overflow happens the value swaps to a negative value. The only difference is that the value goes up a lot more when scrolling down (35725856). When scrolling up the value only goes up for a smaller amount (65536) i could check for that amount but i am not convinced that this is constant for every mouse out there and it looks a bit odd to me. Has anyone more knowledge? Thanks Quote Link to comment Share on other sites More sharing options...
beo6 Posted January 24, 2014 Author Share Posted January 24, 2014 (edited) ok. checking if the value changed about that amount is not reliable. i also have sometimes the value change about 35725848 when scrolling down. //Edit: here is a function that seems to work for me. Script.mouseWheel = 0 Script.wheelUp = 65536 Script.wheelDown = 35725848 function Script:GetMouseWheelDirection() local context = Context:GetCurrent() local window = context:GetWindow() local wheelReturn = 0 local mouseWheelPos = window:GetMousePosition().z if (self.mouseWheel ~= mouseWheelPos) then if ( mouseWheelPos > self.mouseWheel+self.wheelUp ) then wheelReturn = 1 System:Print("Mouse wheel DOWN! ") elseif ( mouseWheelPos < self.mouseWheel+self.wheelDown ) then wheelReturn = 2 System:Print("Mouse wheel UP! ") end self.mouseWheel = mouseWheelPos end return wheelReturn end It returns 0 when the wheel position didn't changed and 1 for Down or 2 for Up. Maybe there is a better way. I will have to check if it works on other PCs etc. Edited January 24, 2014 by beo6 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.