({{, (RefLink[ButtonFunction, paclet:ref/ButtonFunction])
is an option for the low-level function (RefLink[ButtonBox, paclet:ref/ButtonBox]) that specifies the function to execute when the button is active and is clicked. }})

OpenersNotesSection(Spacer1)Details

The default setting for (RefLink[ButtonFunction, paclet:ref/ButtonFunction]) causes the button to paste its contents at your current notebook selection.

(RefLink[ButtonFunction, paclet:ref/ButtonFunction]) is used only with the setting (RefLink[Enabled, paclet:ref/Enabled])->(RefLink[True, paclet:ref/True]), either for the individual button or for the cell that contains it.

With (RefLink[ButtonFunction, paclet:ref/ButtonFunction])->f, the first argument supplied to f is specified by the setting for (RefLink[ButtonSource, paclet:ref/ButtonSource]), and the second argument by the setting for (RefLink[ButtonData, paclet:ref/ButtonData]).

Standard Wolfram Language precedence rules require parentheses in (RefLink[ButtonFunction, paclet:ref/ButtonFunction])->(body&).

Settings for (RefLink[ButtonFunction, paclet:ref/ButtonFunction]) are often inherited from button styles via the (RefLink[ButtonStyle, paclet:ref/ButtonStyle]) option.

With the default setting (RefLink[Evaluator, paclet:ref/Evaluator])->(RefLink[None, paclet:ref/None]), the expression constructed from the button function is sent to the front end for evaluation.

OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Create a button that opens a new notebook when clicked:

CellPrint[Cell[BoxData[ButtonBox["new",ButtonFunction->(FrontEndToken["New"]&)]],"Text"]]

new

Do the same thing using a Wolfram Language function:

CellPrint[Cell[BoxData[ButtonBox["new",Evaluator->Automatic,ButtonFunction->(NotebookCreate[]&)]],"Text"]]

new

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Button, paclet:ref/Button])  ▪  (RefLink[Evaluator, paclet:ref/Evaluator])  ▪  (RefLink[NotebookApply, paclet:ref/NotebookApply])  ▪  (RefLink[ButtonNotebook, paclet:ref/ButtonNotebook])}})}})