Element: beforexrselect event
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.
Thebeforexrselect event is fired before WebXR select events (select,selectstart,selectend) are dispatched. It can be used to suppress XR world input events while the user is interacting with a DOM overlay UI.
This eventbubbles, iscancelable and iscomposed.
In this article
Syntax
Use the event name in methods likeaddEventListener(), or set an event handler property.
addEventListener("beforexrselect", (event) => { })onbeforexrselect = (event) => { }Event type
AnXRSessionEvent. Inherits fromEvent.
Event properties
Event availability
Thebeforexrselect event is a global event and available to the following interfaces:
Examples
To suppress WebXR select events (select,selectstart,selectend), an application can listen for thebeforexrselect event. The event bubbles, so a call topreventDefault() on the DOM overlay element will prevent any WebXR select events within this container allowing interaction with the DOM element and avoiding duplicate event input to the XR world.
document .getElementById("xr-overlay") .addEventListener("beforexrselect", (ev) => ev.preventDefault());Specifications
| Specification |
|---|
| WebXR DOM Overlays Module> # onbeforexrselect> |
Browser compatibility
See also
selecteventselectstarteventselectendevent