Does MOUSE_WHEEL have a min delta value before it fires?

走远了吗. 提交于 2019-12-23 08:53:14

问题


I am having some trouble with MOUSE_WHEEL delta values. It seems like the event doesn't fire unless I REALLY spin the dammed wheel. Which makes sense because the only values I get range from 3-30. I was hoping to catch 1-3 as well because if I just spin a few notches, nothing triggers and the app feels sluggish.

FYI every other program on my machine feels those 1-notch spins just fine so it's not the mouse. Will AS3 not fire if the delta is less than 3?

Here is the code

private function handleMouseWheel(e:MouseEvent):void {
trace(e.delta); 
    // Output is always more/less than +/- 3 
}

private function handleStageInit(e:Event):void {
    stage.addEventListener(MouseEvent.MOUSE_WHEEL, handleMouseWheel);
}

回答1:


AS3 doesn't have any customizable value for wheel sensitivity.

The way it works, I believe, is dependent on BOTH the physical mouse, and the OS settings.

For instance, in windows you set the sensitivity of various mouse settings in ControlPanel -> Mouse.
In the Wheel tab, the user can set how many lines (eg. delta) the wheel does for each physical notch. The default is 3.

At the same time, each physical mouse has different notch sensitivity, eg. how much you need to move it to register a 'notch' in the OS.

I believe the swf's container also has some influence as well, so it may behave differently in different browsers, and as a projector, and in your IDE.

For browsers, most people seem to bypass flash and listen/pass the JavaScript scroll wheel events into flash:

See these libraries:

https://github.com/digi604/As3-Mouse-Wheel-Fixer

http://labs.byhook.com/2010/04/09/flash-mouse-wheel-support/




回答2:


According to ilike2Flash the change in the delta may be dependent on the user's mouse.




回答3:


You have a problem in your code or device, please take a look at this sample(you can right click to view the code). It works just fine on my machine.




回答4:


AS3 fire only +3 (up scroll) and -3 (down scroll), but we can calculate our requirements by dividing some constant.

import flash.events.MouseEvent;

stage.addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheelHandler);

function mouseWheelHandler(ev){
    trace(ev.delta/3); // +1 or -1
    trace(ev.delta/6); // +.5 or -.5
}


来源:https://stackoverflow.com/questions/6240469/does-mouse-wheel-have-a-min-delta-value-before-it-fires

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!