Skip to main content
Home Forums Silverlight Programming Report a Silverlight Bug MouseLeave is not always called
11 replies. Latest Post by avbersSL on October 2, 2008.
(0)
VladF
Member
216 points
87 Posts
07-28-2007 8:03 PM |
The MouseLeave event is not always called when I move mouse fast.
Here you will find an example application showing this bug. It has 2 text blocks counting how many times MouseLeave was called and how many times it failed and MouseMove was used to cancel mouse capturing.
using
{
InitializeComponent();
}
area.SetValue(LeftProperty, p.X - area.Width / 2);
area.SetValue(TopProperty, p.Y - area.Height / 2);
area.MouseLeftButtonUp +=
Children.Add(area);
area.CaptureMouse();
area.ReleaseMouseCapture();
Children.Remove(area);
HideArea();
<
>
</
Pirashan...
14 points
15 Posts
08-01-2007 9:02 AM |
Hello,
One point is that it may be due to the fact that you are moving the mouse pointer fast and another may be due to the fact that your ellipse and textblocks are overlapping each other.
To overcome this problem give Canvas .Zindex and absolute positioning like Canvas.Left and Canvas.Top properties to your ellipse and textblocks and check whether it works fine or not.
Regards
Pirashanthan A
08-01-2007 6:24 PM |
Ellipses do not overlap with text blocks in most cases - just do not move ellipses over text blocks. And they have absolute coordinates set - otherwise you would be able to move them. Z-Index won't help in this case.
I consider this a bug but see no response from Microsoft.
swirling...
Participant
1348 points
385 Posts
08-01-2007 7:04 PM |
I think the problem is that the mouse never enters the ellipse in the first place. When you're moving the mouse fast, I guess it can already be off the ellipse by the time it is added to the canvas. If you add a MouseEnter counter, I think you will see that the times MouseLeave is not fired are also the times MouseEnter is not fired.
08-02-2007 6:48 PM |
Did you run the sample app I posted? You can just press the left mouse button - ellipse will be created, mouse will be in the middle of the ellipse - then you move mouse fast enough and MouseLeave is not called even so mouse left ellipse boundaries.
08-02-2007 7:38 PM |
Yes, I did run your app. For me, the only times the MouseLeave event did not fire were when I was moving the mouse while clicking. I tried at least a hundred times creating an ellipse while the mouse was still, and then moving off of it as fast as I could, but it always worked fine that way.
08-03-2007 8:53 PM |
I just tried it again. From 30 attempts I got 4 failed MouseLeaves. And the speed of mouse movement is not that big (I use laptop and touchpad). What is also interesting is that in one particular direction failures happen more offten - when I move mouse to the left-bottom.
08-06-2007 12:23 PM |
Well, since I'm not able to reproduce it, I'm inclined to think it's something particular with your system. Have you tried it on other machines?
It would be nice if we could get someother people out there to say whether or not they are able to reproduce it...
wjchrist...
104 points
51 Posts
09-04-2008 5:11 PM |
I'm having a similar issue.
I have a StackPanel that has 7 user controls in it (of the same type). Each UserControl has a Slider control in it. I toggle the visibility of the Slider inside my UserControl to visible when the mouse hovers over the UserControl.
If you run the mouse quickly over the UserControls, the MouseLeave event does not always fire. It tends to do this more when I move the mouse quickly over the Slider section of the UserControls. I've noticed that if I put a lot of padding around the Slider, the UserControl is more apt to fire the MouseLeave event.
Simbalight
245 points
09-09-2008 10:48 AM |
VladF:
I didn't try your code but from the postings I can see that you create elements at the cursor's position. The problem is that MouseEnter is never called, when you create the element. Then when you move the cursor fast enough, the cursor will never hit the element in it's movement. MouseEnter won't be called and thus MouseLeave will neither because the UI never recognizes the cursor was over the element. Up to now I don't know any workaround.
Would be great to get some feedback from MS if this is working as intended.
10-02-2008 10:45 AM |
I tested this on SL2RC0 and I cannot reproduce the bug. Anyone else have better luck with SL2RC0?
avbersSL
164 points
77 Posts
10-02-2008 1:50 PM |
Seeing this too..