pointercancel | onpointercancel event
Dispatched when either (1) the system has determined that a pointer is unlikely to continue to produce events (for example, due to a hardware event), or (2) after having fired the pointerdown event, the pointer is subsequently used to manipulate the page viewport (for example, panning or zooming).
Note As of Internet Explorer 11, the Microsoft vendor prefixed version of this event (MSPointerCancel) is no longer supported and may be removed in a future release. Instead, use the non-prefixed lowercase name, pointercancel, which is better for standards compliance and future compatibility.
|HTML Attribute||<element onpointercancel = "handler(event)">|
|addEventListener Method||object.addEventListener("pointercancel", handler, useCapture)|
Event handler parameters
- handler [in]
Function to execute when the event is dispatched
- Pointer Events, Section 5.2.4
This event occurs when the pointer (touch or pen contact) is removed from the system. Here are common reasons why this might happen:
- A touch contact is canceled by a pen coming into range of the surface.
- The device doesn't report an active contact for more than 100ms.
- A mapping for a device's monitor changes while contacts are active. For example, the user changes the position of a screen in a two screen configuration.
- The desktop is locked or the user logged off.
- The number of simultaneous contacts exceeds the number that the device can support. For example, if a device supports only two contact points, if the user has two fingers on a surface, and then touches it with a third finger, this event is raised.
When the pointercancel event is raised for a pointer, the app won’t receive any other events for that pointer, including pointerup . The app should perform any necessary cleanup as required for the pointer. For example, if the app maintains a pointer list, the app should remove the pointer from the list.
You shouldn't treat this event like an pointerup event. When a pointer is removed, the app should cancel any ongoing work. The following example shows how you might handle pointer events if the target is a button:
- When the app receives an pointerdown event, highlight the button, and then show the button as pressed
- When the app receives an pointerup (completed action) event remove the highlighting for the button and then show the button as raised, and execute the button's click handler
- When the app receives an pointercancel (aborted action) event, remove the highlighting for the button, show the button as raised, do any necessary clean up, and don't execute the button's click handler.