openOMSI GitHub Discord

Docs / Making content / HTML textures

Touch and mouse

1 min readEdit this pagedocs/HTMLTEXTURE.md

The app passes presses, releases and movements of the pointer on the texture to the page. They turn into events on the element under the pointer and bubble up through its parents:

  • pointerdown, pointerup, mousedown, mouseup, click, mousemove

You can listen in three ways:

HTML
<button onclick="doSomething()">Press</button>
JavaScript
el.onclick = function (event) { ...
};
el.addEventListener('click', function (event) { ...
});

The event object has type, x, y (in texture pixels), target, stopPropagation() and preventDefault(). A click needs both the press and the release on the page.

There is no keyboard input, no hover and no drag and drop. Build keypads and lists from buttons or boxes and react to click.

Something wrong or missing? Fix it on GitHub or open an issue.

↑↓ to move↵ to open