Export (0) Print
Expand All

ReleaseMouseCapture

Silverlight

Disables mouse capture for the object.

object.ReleaseMouseCapture()

The ReleaseMouseCapture method disables mouse capture for a plug-in that has captured the mouse by using the CaptureMouse method. When a plug-in instance has captured the mouse, it receives mouse input regardless of whether the cursor is within its borders. The mouse is typically captured only during drag operations.

For more information on basic concepts, see Mouse Support. Note that the Mouse Support topic is written primarily for users of the managed API, and may not have code examples or specific information that address the JavaScript API scenarios.

The following JavaScript example shows the mouse being captured and released by using event handler functions for the MouseLeftButtonDown and MouseLeftButtonUp events.

// Display the current mouse position for the Rectangle object.
function onMouseMove(sender, mouseEventArgs)
{
    var msg = "x:y = " + mouseEventArgs.getPosition(null).x + ", " + mouseEventArgs.getPosition(null).y;
    sender.findName("statusTextBlock").Text = sender.Name + ": " + msg;
}

// Enable mouse capture when the mouse button is pressed over the green Rectangle object.
function onLeftButtonDown(greenRect, mouseEventArgs) 
{
    greenRect.captureMouse();
}

// Disable mouse capture when the mouse button is released over the green Rectangle object.
function onLeftButtonUp(greenRect, mouseEventArgs) 
{
    greenRect.releaseMouseCapture();
}

Community Additions

ADD
Show:
© 2014 Microsoft