Skip to main content

Button

Button[label_, action_]

represents a shorthand notation for InputButton with event-handler made for compatibility with Mathematica.

For example

Button["Click to beep", Beep[]]

This button changes the color of the disk each time you click it:

Module[{b = List @@ Red}, {Button["change", 
b = RandomReal[{0, 1}, 3]],
Graphics[{RGBColor[Offload[b]], Disk[]}]}]

This button changes position each time you click it:

Module[{pt = {0, 0}}, 
Framed@Graphics[
Inset[Button["Click Me", pt = RandomReal[{-1, 1}, 2]], Offload[pt]],
PlotRange -> {{-1,1}, {-1,1}}, Controls->False]]