msSetPointerCapture method

Assigns the current pointer (touch, pen, or mouse) and MSPointerEvents to a specific element.

 

Syntax

object.msSetPointerCapture(pointerId);

Parameters

  • pointerId [in]
    Type: long

    Identifier of the pointer that to assign to the element.

Return value

This method does not return a value.

Remarks

This method is used to ensure that an element continues to receive MSPointerEvents even if the contact moves off the element. No other pointers are affected, only the assigned pointer. Capturing the current pointer can improve usability by reducing the touch precision required when interacting with an element.

For example, if a button is touched and held, and the user's finger slides off the button before raising it (breaking the contact), the button might not get the IHTMLDocument8::onmspointerup event. This could cause the button to stay depressed forever. By assigning the pointer to the button element with IHTMLElement7::msSetPointerCapture the button receive pointer events, including the IHTMLDocument8::onmspointerup event that signals the button to return to its initial state.

The capture will be released when the pointer is removed (IHTMLDocument8::onmspointerup) or explicitly released by calling the IHTMLElement7::msReleasePointerCapture method. There are cases the element could lose the capture. For example, if the touch moves outside the Windows Internet Explorer window or some other element captures the touch, then the element that had the capture will lose the capture. The element that lost the capture will receive a onmslostpointercapture event.

When a pointer is captured to an element, the parent and ancestor elements receive a onmsgotpointercapture event during capture and bubble phase.

Note  IHTMLElement7::msSetPointerCapture does not change panning, zooming, and other behaviors. To prevent panning and other default touch behaviors, use IHTMLCSSStyleDeclaration2::msTouchAction. For more information about controlling touch behavior and using multi-touch, see Guidelines for Building Touch-friendly Sites.

 

See also

IHTMLElement7::msReleasePointerCapture

onmsgotpointercapture

MSPointerEvent

IHTMLElement2::releaseCapture

IHTMLElement2::setCapture