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
HTML要素に値が入力(確定)されたときに実行する処理を登録します。
| 引数名 | 内容 | 備考 | オプション | デフォルト値 |
|---|---|---|---|---|
| void | 無効化 | falseが指定された場合にはブロックは実行されない | ○ | nil |
| ... | ブロック | 実行される処理 |
なし