Thursday, June 12, 2008

My Neurons Lack those Synapses

Well, Mousketeers, here's a little Wpf 'n' Proof you probably didn't ever think about. What does hit testing have to do with moving the mouse? I just got a strong Wpf of illogicalitude, to me anyway.

There is on any Wpf control a method called OnMouseMove. You get this event "when the mouse pointer is moved over the control," is says in the docs. It doesn't mention any time when you might not get this event when the mouse moves.

There is a property of UIElement called IsHitTestVisible. This determines "whether this element can possibly be returned as a hit test result from some portion of its rendered content." So, you might call canvas.InputHitTest(mousePoint) to see what control the mouse is over. If there were some controls you did not want this method to return, you could set IsHitTestVisible false on them, and then you would not have to write the extra logic in your code.

Well, surprise. If a control is not hit-test visible, it also does not generate mouse move events. So if you have mouse-tracking code running, it is as if the mouse disappears whenever it is over those controls you don't want the InputHitTest to see.

To me, those two things are (or should be) separate concepts. Mr. Gates disagrees.

0 Comments:

Post a Comment

<< Home