#655 – Bubbling Mouse Events Swallowed by Some Controls

When you click a mouse button on a Label control, you’ll see a series of tunneling and bubbling events, as shown below.

However, if you click a mouse button on a TextBox control, you’ll only see some of these events fire.  Specifically, handlers that you define will only see the PreviewXxx versions of the events.  The other events are swallowed by the TextBox control.

In general, controls that do something as the result of a user pressing a mouse button will swallow the related events.  Clicking within a TextBox gives it focus.  Clicking on a Button or ComboBox also results in the control responding to the click, so these controls also swallow the non-preview events.

Advertisements