I am writing a program that connects P5 with the HTML DOM. I want to have a HTML button when pressed pass along an argument to a function I created. I know I can add an event and callback function to a variable. I am wondering if it possible to add an argument with the callback function.
This is what I have
HTML
Button
P5
let btn;
function setup(){
btn = select("#btn");
btn.mousePressed(myFunction);
}
function myFunction(){
}
What I want to do
let btn;
function setup(){
btn = select("#btn");
btn.mousePressed(myFunction(myArg));
}
function myFunction(arg){
x = x + arg;
}
Any assistance would be appreciated