pub static changed: ChangedInternalTypeExpand description
The .changed() function is called when the value of an element changes. This can be used to attach an element specific event listener.
Examples
let sel;
function setup() {
textAlign(CENTER);
background(200);
sel = createSelect();
sel.position(10, 10);
sel.option('pear');
sel.option('kiwi');
sel.option('grape');
sel.changed(mySelectEvent);
}
function mySelectEvent() {
let item = sel.value();
background(200);
text("it's a " + item + '!', 50, 50);
}let checkbox;
let cnv;
function setup() {
checkbox = createCheckbox(' fill');
checkbox.changed(changeFill);
cnv = createCanvas(100, 100);
cnv.position(0, 30);
noFill();
}
function draw() {
background(200);
ellipse(50, 50, 50, 50);
}
function changeFill() {
if (checkbox.checked()) {
fill(0);
} else {
noFill();
}
}Parameters
fxn function to be fired when the value of
an element changes.
if false is passed instead, the previously
firing function will no longer fire.