Mouse Scroll Wheel events

Yes I know, I’m just the editor in the game and it would be easier in the corona simulator. And so i’m have to compile the app on the Mac.  In any case, thank you)

Hi all,

Just jumping on this as I’m attempting to use the mouse event’s scrollY property but I’m getting some strange results that I wonder if anyone could shed some light on…

Here is some simple test code I’m running:

system.activate("mouse"); -- Called when a mouse event has been received. local function onMouseEvent( event )     print("event.scrollY = "..event.scrollY); end -- Add the mouse event listener. Runtime:addEventListener( "mouse", onMouseEvent )

When I swipe my finger along my Magic Mouse (i.e.: the “scroll wheel”), the values for scrollY jiggle about a bit at the start and then reduce smoothly as I’d expect, but then as they reach zero, every time they suddenly jump again a few times. What this means is that the thing I’m trying to move “jerks” at the end of the swipe and jumps a few times after initially taking a nice smooth course. I’ve included the values that are output below…

This happens every single time - you’ll see the scrollY value reverts to zero (or minus zero?!) and then jumps to minus 1.2 or so. These jumps happen after I’ve taken my finger off the mouse (i.e.: I’ve stopped my swipe).

I’m confused as to why they start out jumping about (always with a random minus zero after a few values are printed out) and then seem to go smoothly before jumping around again at the end. The same pattern occurs every time, with different values. Any ideas?

Thanks,

Ian

Jan 26 12:58:32.280 event.scrollY = -1.0000610351562 \<\<\<\<\< JIGGLING ABOUT Jan 26 12:58:32.297 event.scrollY = -1.7001037597656 Jan 26 12:58:32.310 event.scrollY = -3.1001892089844 Jan 26 12:58:32.322 event.scrollY = -5.3003234863281 Jan 26 12:58:32.334 event.scrollY = -3.6002197265625 Jan 26 12:58:32.348 event.scrollY = -5.5003356933594 Jan 26 12:58:32.361 event.scrollY = -3.5002136230469 Jan 26 12:58:32.373 event.scrollY = -6.3003845214844 Jan 26 12:58:32.387 event.scrollY = -3.6002197265625 Jan 26 12:58:32.402 event.scrollY = -0 \<\<\<\<\< RANDOM ZERO (or -0) Jan 26 12:58:32.415 event.scrollY = -8.9005432128906 \<\<\<\<\< THE SMOOTH REDUCTION STARTS Jan 26 12:58:32.429 event.scrollY = -8.6005249023438 Jan 26 12:58:32.442 event.scrollY = -8.1004943847656 Jan 26 12:58:32.456 event.scrollY = -7.9004821777344 Jan 26 12:58:32.472 event.scrollY = -7.4004516601562 Jan 26 12:58:32.484 event.scrollY = -7.200439453125 Jan 26 12:58:32.500 event.scrollY = -6.7004089355469 Jan 26 12:58:32.520 event.scrollY = -6.6004028320312 Jan 26 12:58:32.541 event.scrollY = -6.0003662109375 Jan 26 12:58:32.561 event.scrollY = -5.5003356933594 Jan 26 12:58:32.578 event.scrollY = -5.1003112792969 Jan 26 12:58:32.595 event.scrollY = -4.6002807617188 Jan 26 12:58:32.613 event.scrollY = -4.2002563476562 Jan 26 12:58:32.631 event.scrollY = -3.8002319335938 Jan 26 12:58:32.649 event.scrollY = -3.5002136230469 Jan 26 12:58:32.668 event.scrollY = -3.3002014160156 Jan 26 12:58:32.686 event.scrollY = -2.9001770019531 Jan 26 12:58:32.706 event.scrollY = -2.8001708984375 Jan 26 12:58:32.726 event.scrollY = -2.5001525878906 Jan 26 12:58:32.744 event.scrollY = -2.3001403808594 Jan 26 12:58:32.763 event.scrollY = -2.1001281738281 Jan 26 12:58:32.784 event.scrollY = -1.9001159667969 Jan 26 12:58:32.804 event.scrollY = -1.8001098632812 Jan 26 12:58:32.823 event.scrollY = -1.60009765625 Jan 26 12:58:32.823 event.scrollY = -1.5000915527344 Jan 26 12:58:32.844 event.scrollY = -1.4000854492188 Jan 26 12:58:32.865 event.scrollY = -1.3000793457031 Jan 26 12:58:32.887 event.scrollY = -1.1000671386719 Jan 26 12:58:32.887 event.scrollY = -1.0000610351562 Jan 26 12:58:32.909 event.scrollY = -1.0000610351562 Jan 26 12:58:32.930 event.scrollY = -0.90005493164062 Jan 26 12:58:32.949 event.scrollY = -0.800048828125 Jan 26 12:58:32.971 event.scrollY = -0.70004272460938 Jan 26 12:58:32.991 event.scrollY = -0.70004272460938 Jan 26 12:58:32.991 event.scrollY = -0.60003662109375 Jan 26 12:58:33.010 event.scrollY = -0.60003662109375 Jan 26 12:58:33.025 event.scrollY = -0.60003662109375 Jan 26 12:58:33.041 event.scrollY = -0.50003051757812 Jan 26 12:58:33.057 event.scrollY = -0.50003051757812 Jan 26 12:58:33.073 event.scrollY = -0.50003051757812 Jan 26 12:58:33.089 event.scrollY = -0.4000244140625 Jan 26 12:58:33.105 event.scrollY = -0.4000244140625 Jan 26 12:58:33.121 event.scrollY = -0 \<\<\<\<\< I WOULD EXPECT IT TO END NOW Jan 26 12:58:33.138 event.scrollY = -0 Jan 26 12:58:33.154 event.scrollY = -0 Jan 26 12:58:33.170 event.scrollY = -1.2000732421875 \<\<\<\<\< BUT YOU GET THESE ANOMALIES Jan 26 12:58:33.186 event.scrollY = -0 Jan 26 12:58:33.203 event.scrollY = -0 Jan 26 12:58:33.220 event.scrollY = -0 Jan 26 12:58:33.237 event.scrollY = -0 Jan 26 12:58:33.254 event.scrollY = -1.1000671386719 \<\<\<\<\< AND THEY CONTINUE NOW AND AGAIN Jan 26 12:58:33.272 event.scrollY = -0 Jan 26 12:58:33.289 event.scrollY = -0 Jan 26 12:58:33.307 event.scrollY = -0 Jan 26 12:58:33.324 event.scrollY = -0 Jan 26 12:58:33.342 event.scrollY = -0 Jan 26 12:58:33.359 event.scrollY = -0 Jan 26 12:58:33.379 event.scrollY = -0 Jan 26 12:58:33.398 event.scrollY = -0 Jan 26 12:58:33.418 event.scrollY = -0.90005493164062 Jan 26 12:58:33.418 event.scrollY = -0 Jan 26 12:58:33.440 event.scrollY = -0 Jan 26 12:58:33.461 event.scrollY = -0 Jan 26 12:58:33.482 event.scrollY = -0 Jan 26 12:58:33.499 event.scrollY = -0 \<\<\<\<\< UNTIL THEY FINALLY TAIL OFF AND THE EVENTS STOP

Ian, these are the raw values coming from OS X.  They are unaltered by Corona.

So, if you’re seeing any “jerkiness” from it, well then that’s coming from Apple or your input device.

You may also get scroll values of zero while you are scrolling if you are moving your mouse as well.  This is because at the OS level, mouse movement events and scrollwheel events are received as separate events.

How you *should* use scrollwheel events is apply their scrollX/Y values as offsets to the object you want to scroll.  As in, you’ll want to translate and object based on those scroll values.  If you do that, then you’ll find out that these values will work just fine.

Also note that this is still not an official feature.  It’s not documented and is still in the experimental stage.

The values returned by OS X do not have Corona’s content scale applied to them, which we’re still considering doing in the near future when we’re ready to make this an official feature.

Got something working…

https://forums.coronalabs.com/topic/61465-osx-scrollview-working-with-mouse-wheel/

When you move the mouse cursor to the Change event.x and event.y. If you turn the wheel while you move the cursor over the event.scrollY reset to zero it’s not right. event.scrollY and event.x must not depend on each other. Please correct, it is very necessary for my game on mac.

I believe Corona have started work on official support for this with a scrollview but not sure if that’s what you’re looking for. Wasn’t aware event.scrollX was reset when moving the mouse - it never came up as an issue in what I was doing. If you find a solution in the meantime then I’d like to see what you’ve come up with if you have a moment to post it.

Thanks.

We do not have official support for mouse scroll support.  It’s in the experimental stage.  Pending feedback on actual usage.

At the native level, mouse move events and mouse scroll wheel events are separate events.  So, what you are seeing is normal.  That is, if you move the mouse, the scroll values will be zero.  When you scroll the wheel, the you’ll receive new scroll values and the mouse coordinates are of the mouse cursors last known position.

The idea is that you should simply offset/translate your view with the scroll values you receive.  Do not attempt any type of momentum scrolling.  If you do this, then your view will scroll at the same rate as all other apps on the desktop.  And OS X will simulate momentum based scroll values for you when using a trackpad or MagicMouse so you won’t have to.  Versus Windows an Android scroll based on line heights and characters width using the system’s default font size.