Sending Values Between Functions

Thank you so much, that really helped. Here is the working code in case anyone else needs it as reference.

//global variables
let button;
let inp;

function setup() {
  inp = createInput('');
  inp.position(100,100);
  newInput = inp.input(myInputEvent);
  button = createButton('click me');
  button.position(19, 19);
  button.mousePressed(changeText);
  createCanvas(500, 500);
}

function myInputEvent() {
  var myInput = this.value();
  return myInput;
}

function changeText(){
  text (inp.value(), 100, 200);
}
1 Like