English
Appearance
English
Appearance
Related references:
If the host page overlays its own buttons, hint layers, or guides, those layers may block clicks inside the iframe. In that case, you can forward host-layer coordinates into the scene.
The current advanced API method is:
await api.dispatchTouchEvent(x, y);overlay.addEventListener('click', async (event) => {
await api.dispatchTouchEvent(event.clientX, event.clientY);
});Note: x and y should be coordinates inside the iframe, not host-page coordinates.
If the overlay and iframe have exactly the same size and position, you can pass the values directly. Otherwise you need to convert coordinates between the two spaces.
dispatchTouchEvent():
So what you should pass in is iframe-page coordinates, not raw host-page coordinates.
This is commonly paired with api.on('click', ...):
const target = await api.getObject('rabbit');
await api.on('click', ({ target }) => {
console.log('Internal object clicked', target);
}, target);x and y must be numbers0, the event will not take effectIf you only need a few custom buttons, it is usually better to place them away from critical interaction areas. Use dispatchTouchEvent() only when the host layer really needs to take over the click chain.