(p5element).changed

def setup
  createCanvas(100, 100)
  background('gray')
  textSize(20)
  inp = createInput
  inp.position(0, 0)
  inp.size(100 - 8)
  inp.input do          # 入力のつど
    background('gray')
    fill('white')
    text(inp.value, 10, 60)
  end
  inp.changed do        # 入力確定(値変更)
    background('gray')
    fill('yellow')
    text(inp.value, 10, 60)
  end
end
def setup
  textAlign(CENTER)
  background('gray')
  sel = createSelect
  sel.position(10, 10)
  sel.option('gray')
  sel.option('red')
  sel.option('green')
  sel.option('blue')
  sel.selected('gray')
  sel.changed do
    background(sel.value)
  end
end
def setup
  checkbox = createCheckbox('fill', false)
  checkbox.position(0, 105)
  checkbox.changed do
    if checkbox.checked
      fill('yellow')
    else
      noFill
    end
  end
  noFill
end

def draw
  background(220)
  rect(10, 10, 80, 80)
end

p5.jsリファレンス(参考情報)

[p5.js] changed

概要

HTML要素に値が入力(確定)されたときに実行する処理を登録します。

書式

obj.changed([void]) do ... end

引数

引数名内容備考オプションデフォルト値
void無効化falseが指定された場合にはブロックは実行されないnil
...ブロック実行される処理

戻値

なし

備考

関連

(p5element).input