开发者

Silverlight MouseMove inconsistency for Chrome vs FF/IE

开发者 https://www.devze.com 2023-01-04 11:44 出处:网络
I\'ve got a listbox with images. I\'m capturing MouseMove. In FF (Win7 & OSX) & also i开发者_如何学编程n IE8, this fires whenever the mouse is moved over the images. In Chrome (on OSX), howeve

I've got a listbox with images. I'm capturing MouseMove. In FF (Win7 & OSX) & also i开发者_如何学编程n 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号