为什么 WheelDelta = 120?

发布于 2024-12-09 21:45:37 字数 377 浏览 5 评论 0原文

我正在处理鼠标事件,特别是 OnMouseWheel。许多代码示例将视图更改的距离(或 3D 应用程序中的缩放 fi)称为 Distance = Sign(WheelDelta)*ConstantDistance = WheelDelta / WHEEL_DELTA 或类似的内容kind - 假设 WheelDelta 始终是 120 的倍数(WHEEL_DELTA 常量 = 120)。

我已经发现在触摸界面/平板电脑中输入可能取决于滚动长度。

我想知道为什么 Microsoft 将默认 WheelDelta 设置为 120,为什么不设置为 100 或 10 或其他值?在其他什么情况下,车轮增量可能与 120 不同?

I'm working with mouse events, specifically OnMouseWheel. Many code samples refer to distance the view changes (or zoom f.i. in 3D application) as Distance = Sign(WheelDelta)*Constant or Distance = WheelDelta / WHEEL_DELTA or something of that kind - assuming that WheelDelta is always a multiple of 120 (WHEEL_DELTA constant = 120).

I already found that in touch interfaces / tablets input may depend on scrolling length.

I was wondering why Microsoft has set default WheelDelta to 120, why not 100 or 10 or anything else? In what other cases wheel delta may be something different from 120?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

半岛未凉 2024-12-16 21:45:37

Qt 文档更详细地解释了为什么它实际上是 120:

QPoint QWheelEvent::angleDelta() const

返回轮子旋转的距离(以八分之一度为单位)。一个
正值表示车轮向前旋转远离
用户;负值表示车轮向后旋转
用户。

大多数鼠标类型以 15 度为步长工作,在这种情况下,增量值为
120 的倍数;即,120 个单位 * 1/8 = 15 度。

但是,一些鼠标具有更高分辨率的轮子并发送增量值
小于 120 个单位(小于 15 度)。为了支持这种可能性,您
可以累积添加事件的增量值,直到值达到 120
到达,然后滚动小部件,或者您可以部分滚动小部件
对每个轮子事件的响应。

https://doc.qt.io/qt-5/qwheelevent.html#角度增量

The Qt Documentation elaborates a bit more on why it is actually 120:

QPoint QWheelEvent::angleDelta() const

Returns the distance that the wheel is rotated, in eighths of a degree. A
positive value indicates that the wheel was rotated forwards away from the
user; a negative value indicates that the wheel was rotated backwards toward
the user.

Most mouse types work in steps of 15 degrees, in which case the delta value is
a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.

However, some mice have finer-resolution wheels and send delta values that are
less than 120 units (less than 15 degrees). To support this possibility, you
can either cumulatively add the delta values from events until the value of 120
is reached, then scroll the widget, or you can partially scroll the widget in
response to each wheel event.

https://doc.qt.io/qt-5/qwheelevent.html#angleDelta

夏至、离别 2024-12-16 21:45:37

WHEEL_DELTA 不再固定为 120。据我了解,选择这个常量是为了将来实现更精细的分辨率,显然现在就是这样。

请参阅 MSDN< 中的这篇文章< /a>

WHEEL_DELTA is not fixed anymore to 120. As I understand it this constant was chosen to allow for finer resolutions in the future, which obviously is NOW.

See this article from MSDN

悸初 2024-12-16 21:45:37

该问题已标记为已回答,我想我可以提供更多信息。

如果我理解正确的话,WHEEL_DELTA 实际上是 40 而不是 120,120 来自鼠标驱动程序将原始 WHEEL_DELTA 值乘以要滚动的行数,默认情况下为 3。您可以使用

My.Computer.Mouse.WheelScrollLines

以下命令 获取滚动行数:使用 NumericUpDown 控件可以看到,该控件在滚动时通过增量乘以行数来调整值。

只是搞乱了我的滚轮鼠标,一整圈有 18 个制动装置,每个制动装置 20 度(当然我知道这只是世界上鼠标的一小部分样本大小......!)。 40 表明他们觉得半度就足够了,尽管最后一段是假设。

编辑:不是一个散布错误信息的人,经过进一步研究,WHEEL_DELTA 实际上是 120,NumericUpDown 被证明是误报。尽管如此,如果可以将三因子应用到逻辑中,那么其余的讨论都是有效的。

The question is marked as answered already I thought I might provide some more information.

If I understand correctly, WHEEL_DELTA is actually 40 not 120, the 120 comes from the mouse driver multiplying the raw WHEEL_DELTA value by the number of lines to scroll, which is by default 3. You can obtain the scroll line number using

My.Computer.Mouse.WheelScrollLines

This can most easily be seen using a NumericUpDown control, which on scroll adjusts the value by the increment multiplied by that line count.

Just messing with my wheel mouse, there are 18 detents in a full revolution, being 20 degrees per detent (Sure I know that's a small sample size of mouses in the world...!). 40 suggests they felt half degrees were fine enough though this last paragraph is supposition.

EDIT: Not one to spread misinformation, on further study WHEEL_DELTA is in fact 120, NumericUpDown proved to be a false positive. Nonetheless, the rest of the discussion is valid, if one can apply a factor of three to the logic.

私藏温柔 2024-12-16 21:45:37

正如您所注意到的,笔记本电脑触摸板可以滚动(两指或右手大小的滚动区域),在这种情况下,可能会有很多具有非常小的wheelDelta值的事件(要么需要集成,要么可能超时以防止太多重画) 。

此外,不同的操作系统或配置或设备可以具有不同的滚动含义 - 像素、线条或页面。例如 DOM event.deltaMode

最后一些设备(鼠标和触摸板)也允许水平滚动。

上面的内容更具体地针对浏览器 DOM 事件,但同样的问题也可能适用于 Win 事件。

编辑:

Firefox MDN 文档 中,您发现了三个事件可能感兴趣的是:WM_MOUSEWHEEL、WM_MOUSEHWHEEL 和 WM_GESTURE(在触摸设备上平移)。

搜索 Mozilla Bugzilla 数据库 显示了某些 Symantics 和 ALPS 的各种问题触摸驱动程序发送 WM_VSCROLL 而不是 WM_MOUSEWHEEL(如果支持触摸板,则可能相关)。

如果你想要水平鼠标滚动支持,这篇文章来自闪存开发者说:[鼠标滚轮支持] 已在 Vista 中添加,因此如果您使用的是 XP 或 2000,则需要安装 IntelliType Pro 和/或 IntelliPoint 以获得 WM_MOUSEHWHEEL 支持。

@Krom:更多的猜测和松散的事实,但可能对其他人有用:-)

As you have noticed laptop Touchpads can scroll (either two-finger or scroll zone on right hand size), in which case there can be lots of events with very small wheelDelta values (either needing integration, or perhaps timeouts to prevent too many redraws).

Also different OS's or configurations or devices can have different meanings for scrolling - pixels, lines, or pages. e.g. DOM event.deltaMode

Finally some devices (mice and touchpads) also allow horizontal scrolling.

The above is more specific to browser DOM events, but the same issues may apply to Win events too.

Edit:

From the Firefox MDN docs there are three events you are probably interested in: WM_MOUSEWHEEL, WM_MOUSEHWHEEL, and WM_GESTURE (panning on touch devices).

A search of the Mozilla Bugzilla database shows a variety of problems with some Symantics and ALPS touch drivers sending WM_VSCROLL instead of WM_MOUSEWHEEL (may be relevant if supporting touchpads).

If you want horizontal mouse scrolling support, this article from a flash dev says: [mousewheel support] was added in Vista so if you are using XP or 2000 you need IntelliType Pro and/or IntelliPoint installed for WM_MOUSEHWHEEL support.

@Krom: more speculations and loose facts but maybe useful to others :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文