#687 – What Happens If You Forget to Release The Mouse

A user interface element can capture the mouse, asking to receive all future mouse events, no matter where the mouse cursor is located.  You’ll typically capture the mouse in a mouse down or related event and then release the mouse in the corresponding mouse up event so that things go back to normal.

But what happens if something goes wrong and you forget to release the mouse?  At that point, the element that captured the mouse will continue to receive mouse input.  This means that other elements in your application that use the mouse will no longer function.

In the example below, the Raphael label captures the mouse on mouse down, but does not release it on mouse up.  Then when I click on the Button, the Raphael label is still getting the mouse events.

Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #687 – What Happens If You Forget to Release The Mouse

  1. Pingback: Dew Drop – November 9, 2012 (#1,440) | Alvin Ashcraft's Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: