为什么MouseEnter和MouseLeave不可靠? [英] Why are MouseEnter and MouseLeave unreliable?
问题描述
根据此问题,究竟是什么使这些事件不可靠?
According to this question, the answer begins with "The MouseEnter/Leave events are too unreliable to do this."
What exactly makes these events unreliable?
推荐答案
仅每隔一段时间轮询一次鼠标位置.这些事件之一很可能是-鼠标进入或离开,可能发生在轮询发生之间,并且事件无法正确触发.
The mouse position is only polled every so often. It's very possible that one of those events - the mouse entering, or leaving, could occur between when the polls occur, and the events would not fire correctly.
这也做出了一个非常具体的假设,即鼠标的移动将是连续的,而不是离散的-如果用户使用触摸屏显示器该怎么办?如果鼠标直接从控件内部移动到控件外部,而控件之间没有移动怎么办?
This also makes a pretty concrete assumption that mouse movement will be continuous, rather than discrete - what if the user has a touch screen monitor? What if the mouse goes directly from inside the control to being way outside it, with no movement in between?
这篇关于为什么MouseEnter和MouseLeave不可靠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!