Chrome 与 FF/IE 的 Silverlight MouseMove 不一致

发布于 2024-09-06 16:13:55 字数 267 浏览 6 评论 0原文

我有一个带有图像的列表框。我正在捕获 MouseMove。在 FF(Win7 和 OSX)中同样在 IE8 中,每当鼠标移到图像上时都会触发此事件。然而,在 Chrome(OSX 上)中,它仅在按下鼠标按钮时触发。 Chrome 的这种行为实际上非常有用,但前提是我可以控制它,而不是让它在某些浏览器上随机发生。那么有谁知道是否有一些整体设置使其在 Chrome 中以这种方式运行,或者只是 SL 实现中的不一致? 我怀疑是后者,因为我从未在 SL 中找到测试鼠标按钮是否按下的方法。

感谢您的任何帮助。

I've got a listbox with images. I'm capturing MouseMove. In FF (Win7 & OSX) & also in IE8, this fires whenever the mouse is moved over the images. In Chrome (on OSX), however, it only fires while the mouse button is pressed down. This Chrome behaviour would actually be quite useful, but only if I could control it, rather than have it just randomly happen on certain browsers. So does anyone know if there's some overall setting somewhere that's making it behave this way in Chrome, or is it just an inconsistency in SL implementations?
I suspect the latter, since I've never been able to find a way in SL of testing whether the mouse button is down.

Thanks for any help.

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

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

发布评论

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

评论(1

抠脚大汉 2024-09-13 16:13:56

据我了解,问题是当鼠标左键按下时,MouseMove、MouseEnter 和 MouseLeave 事件不会被触发。

我对文本框也有同样的问题。实际上它也发生在 IE 中,我的谷歌搜索告诉我这是设计使然的。进一步的谷歌搜索揭示了原因:该元素正在使用 CaptureMouse() 方法捕获鼠标。所以我刚刚从 TextBox 派生并覆盖 OnMouseMove(...) 方法:

protected override void OnMouseMove(MouseEventArgs e)
{
    base.OnMouseMove(e);
    ReleaseMouseCapture();
}

注意:我不确定,捕获鼠标是否是此方法的基本实现所做的唯一事情,所以我添加了调用后ReleaseMouseCapture(),但注释掉它当然也可以。

As far as I understand the problem is MouseMove, MouseEnter and MouseLeave events are not fired when mouse left button is down.

I had the same problem with TextBox. Actually it happened in IE too and my googling told me it is so by design. Further googling revealed the reason: the element is capturing mouse using CaptureMouse() method. So I have just derived from TextBox and overrode OnMouseMove(...) method:

protected override void OnMouseMove(MouseEventArgs e)
{
    base.OnMouseMove(e);
    ReleaseMouseCapture();
}

Note: I'm not sure, whether capturing mouse is the only thing the base implementation of this method does, so I added ReleaseMouseCapture() after calling it, but commenting it out also works, of course.

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