Jack Brown wrote:
Hi Ron, As to your last post on this topic. Why would you add mouse leave in the creation of a momentary push button?
There are a couple of instances I know of that would cause the MouseUp Event to not be fired for a given control, this is true for both Forms based buttons and WPF based buttons IIRC.
1 Touching or pressing down on a button (MouseDown), but dragging the cursor (or finger) off of the item (MouseLeave) before releasing the button (MouseUp) event occurs will prevent the MouseUp event from firing on the control.
2 Touching a button but having some other object (Alarm Popup perhaps) or application (Primarily PC) steal focus before releasing the mouse or finger will also prevent the MouseUp event from firing on the control.
MouseLeave will fire regardless for either of these two behaviors. But will not fire by itself generally until you move the mouse into and out of the control, or touch some other area of the screen. By also attaching to MouseLeave you ensure that the Toggle action in this case is set back to the off state.
There could be an edge case using MouseLeave I suppose, if one were working with a Tag that could be set true through other means such as if the Controller changed the value to true for some duration, and if you happened to drag your finger (or mouse) across the control the MouseEnter would fire followed by MouseLeave as the touch or mouse cursor moved out of the control and thus could set the Tag to the value specified in the MouseLeave event. Not terribly likely but possible edge case none the less.