Export (0) Print
Expand All

ReleaseMouseCapture Method

Disables mouse capture for the object.

XAML
Cannot use methods in XAML.
Scripting
object.ReleaseMouseCapture()

Remarks

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 whether or not the cursor is within its borders. The mouse is typically only captured during drag operations. For more information on capturing the mouse, see Implementing Drag and Drop.

Examples

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

JavaScript
// 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 is depressed over the green Rectangle object.
function onLeftButtonDown(greenRect, mouseEventArgs) 
{
    greenRect.captureMouse();
}

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

Applies To

Canvas, Ellipse, Glyphs, Image, InkPresenter, Line, MediaElement, Path, Polygon, Polyline, Rectangle, TextBlock

See Also

Silverlight Mouse Support
CaptureMouse
MouseLeftButtonDown
MouseLeftButtonUp
MouseMove

Community Additions

Show:
© 2014 Microsoft