Feb 15, 2011
I was getting some slightly unusual behavior when using the mouse wheel for some zooming/scaling work (only vaguely related to the earlier thread, for those who remember it). Frankly, it is likely that I have a bug in some code, but that wasn't quite enough to explain what I was seeing. Therefore, I used a error logging feature in my app to note the delta being passed in each Mouse Wheel event. I then ran the app and gave the wheel one good spin, which was about the maximum that I would normally ever spin the wheel in one steady, continuous motion. I wasn't going slow, I wasn't going fast, and I rotated it about as much as my finger comfortably could in a single roll.[code]I then rolled it back the other way using the same motion, and got 8 events, mostly under 200, but one of them was -331 and the other was -7940.
View 15 Replies
After a handful of tests, it appears that the wheel event is raised often, which is no surprise, but that the values fluctuate all over the place. With a continuous rotation, or as nearly continuous as I can make it, I can see a series of events with one of them easily being ten times the rest.The problem this presents is that the scaling I am using is not smooth (nor is it standard mathematical scaling, but that's a different story). Each zoom level doubles the size of the objects relative to the previous level, though the distance between them stays the same. I would like to do this by dividing the delta by some factor, and if that is above a threshold, increase the zoom level. That won't work smoothly, in this case. If I make the factor something small enough that I pick up a small rotation, then any larger rotation is likely to include a delta that takes the screen through all zoom levels in a single step. Alternatively, if I make the factor large, then all smaller rotations are simply ignored.One option would be to filter out rotation values below 200 and above 800, or so. I am looking for other alternatives.