Bear with me, because I am very new to JS.
Here is my code for getting the mouse button (including forward and backward) in JS:
// Import any other script files here, e.g.:
// import * as myModule from "./mymodule.js";
runOnStartup(async runtime =>
{
// Code to run on the loading screen.
// Note layouts, objects etc. are not yet available.
runtime.addEventListener("beforeprojectstart", () => OnBeforeProjectStart(runtime));
});
async function OnBeforeProjectStart(runtime)
{
// Code to run just before 'On start of layout' on
// the first layout. Loading has finished and initial
// instances are created and available to use here.
document.addEventListener("mousedown", (e) => {e.preventDefault(); mousedown(e.clientX, e.clientY, e.button)});
runtime.addEventListener("tick", () => Tick(runtime));
}
function mousedown(x, y, button){
console.log(button);
}
function Tick(runtime)
{
// Code to run every tick
}
Simply put, I want to use the 'button' number variable in an event sheet, with as little extra code useage as possible. Any ideas?