({{, (RefLink[PasteButton, paclet:ref/PasteButton])[expr]
represents a button that pastes expr whenever it is pressed. }, {, (RefLink[PasteButton, paclet:ref/PasteButton])[label,expr]
displays with label on the button. }})

OpenersNotesSection(Spacer1)Details and Options

expr is by default pasted at the current insertion point in your input notebook.

(RefLink[PasteButton, paclet:ref/PasteButton])[notebook,label,expr] pastes to the specified notebook.

(RefLink[PasteButton, paclet:ref/PasteButton]) evaluates its arguments in an ordinary way, so that expr is immediately evaluated.

(RefLink[PasteButton, paclet:ref/PasteButton])[(RefLink[Defer, paclet:ref/Defer])[expr]] creates a button which pastes the unevaluated form of expr.

If expr contains a selection placeholder, it will be replaced by your current selection when the paste is done.

Selection placeholders are represented by the character ■ or (RefLink[\[SelectionPlaceholder], paclet:ref/character/SelectionPlaceholder]).

label can be any expression.

(RefLink[PasteButton, paclet:ref/PasteButton]) takes the same options as (RefLink[Button, paclet:ref/Button]).

(RefLink[PasteButton, paclet:ref/PasteButton])[expr] creates a button with equivalent functionality to the one created by (RefLink[Button, paclet:ref/Button])[expr,(RefLink[None, paclet:ref/None]),(RefLink[BaseStyle, paclet:ref/BaseStyle])->"Paste"].

OpenersPrimaryExamplesSection(Spacer1)Examples  (22)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Create a button that will paste its contents:

PasteButton[1]

Supply a different label:

PasteButton["aaa",1]

Create a button to paste an unevaluated expression:

PasteButton[Defer[2+2]]

OpenersExampleSection1(Spacer1)Scope  (2)

OpenersExampleSubsection0(Spacer1)PasteButton Content  (1)

Use any expression as a label:

Table[PasteButton[a],{a,{Style["\[MathematicaIcon]",Large],"string",Framed[x+y],Graphics[Rectangle[],ImageSize->20]}}]

OpenersExampleSubsection1(Spacer1)PasteButton Control  (1)

Paste the result of an evaluation:

PasteButton[HoldForm[Integrate[x,{x,0,1}]],Integrate[x,{x,0,1}]]

Paste a graphics object:

Table[PasteButton[p,Graphics[p[]]],{p,{Rectangle,Disk}}]

OpenersExampleSection2(Spacer1)Options  (13)

OpenersExampleSubsection2(Spacer1)Alignment  (1)

Different predefined alignment options:

Row[Table[PasteButton["y",ImageSize->{Automatic,50},Alignment->a],{a,{Top,Center,Bottom}}],"xxx"]

OpenersExampleSubsection3(Spacer1)Appearance  (1)

(RefLink[Default, paclet:ref/Default]) and "Pressed" appearance:

Table[PasteButton["xxx",Appearance->a],{a,{Automatic,"Pressed"}}]

OpenersExampleSubsection4(Spacer1)Background  (1)

Change the background colors:

Table[PasteButton["xxx",Background->a],{a,{Pink,Green,Gray,Yellow}}]

OpenersExampleSubsection5(Spacer1)BaselinePosition  (1)

Align with the surrounding text:

Row[Table[Framed@PasteButton["b",BaselinePosition->p],{p,{Top,Center,Bottom}}],"xxx"]

OpenersExampleSubsection6(Spacer1)Enabled  (2)

By default (RefLink[PasteButton, paclet:ref/PasteButton]) is enabled:

PasteButton["xxx"]

By setting (RefLink[Enabled, paclet:ref/Enabled])->(RefLink[False, paclet:ref/False]), the button is disabled but visible in its current state:

PasteButton["xxx",Enabled->False]

OpenersExampleSubsection7(Spacer1)Evaluator  (1)

By default the paste operation takes place in the front end:

PasteButton["xxx"]

OpenersExampleSubsection8(Spacer1)FrameMargins  (1)

By setting (RefLink[FrameMargins, paclet:ref/FrameMargins]) you make the button content area larger:

Table[PasteButton["xxx",FrameMargins->m],{m,{0,5,10,20}}]

OpenersExampleSubsection9(Spacer1)ImageMargins  (1)

By setting (RefLink[ImageMargins, paclet:ref/ImageMargins]) you make the button area larger:

Table[PasteButton["xxx",ImageMargins->m,Background->Pink],{m,{0,5,10,20}}]

OpenersExampleSubsection10(Spacer1)ImageSize  (4)

Use preset values:

Table[PasteButton["xxx",ImageSize->i],{i,{Tiny,Small,Medium,Large}}]

Or use any values:

Column[Table[PasteButton["xxx",ImageSize->i],{i,{50,100,150,200}}]]

By setting the second element you can also control the height:

PasteButton["xxx",ImageSize->{Automatic,50}]

Set a fully custom size:

Grid[Table[PasteButton[xxx,ImageSize->{w,h}],{h,{20,30,40}},{w,{30,40,60}}]]

OpenersExampleSection3(Spacer1)Applications  (1)

Make paste buttons for a collection of country strings:

PasteButton/@CountryData["G8"]

OpenersExampleSection4(Spacer1)Properties & Relations  (2)

Use ■ to replace it with the current selection:

PasteButton[Sqrt[\[SelectionPlaceholder]]]

(RefLink[PasteButton, paclet:ref/PasteButton]) is a special case of (RefLink[Button, paclet:ref/Button]):

PasteButton["xxx"]

Button["xxx",NotebookWrite[ButtonNotebook[],"\"xxx\""]]

OpenersExampleSection5(Spacer1)Possible Issues  (1)

(RefLink[PasteButton, paclet:ref/PasteButton]) does not evaluate its arguments on each click:

x=0;PasteButton["xxx",x++]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Button, paclet:ref/Button])  ▪  (RefLink[Paste, paclet:ref/Paste])  ▪  (RefLink[NotebookApply, paclet:ref/NotebookApply])  ▪  (RefLink[Hyperlink, paclet:ref/Hyperlink])  ▪  (RefLink[Defer, paclet:ref/Defer])  ▪  (RefLink[RawBoxes, paclet:ref/RawBoxes])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Introduction to Dynamic, paclet:tutorial/IntroductionToDynamic])}, {▪(RefLinkPlain[Generalized Input, paclet:tutorial/GeneralizedInput])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Palettes, paclet:guide/Palettes])}, {▪(RefLinkPlain[Control Objects, paclet:guide/ControlObjects])}, {▪(RefLinkPlain[Clipboard Operations, paclet:guide/ClipboardOperations])}, {▪(RefLinkPlain[Custom Interface Construction, paclet:guide/CustomInterfaceConstruction])}})}})