I have 2 images on a canvas and each image has it’s own button. When the first button is pressed, the first image is selected. When the second button is pressed, the second image is selected.
button1 = createButton("Select");
button1.position(160, 350);
button1.mousePressed(selectImage);
button2 = createButton("Select");
button2.position(560, 350);
button2.mousePressed(selectImage);
}
function selectImage(){
//button 1 was pressed
//or
//button 2 was pressed
}