WOLFRAM

PasteButton[expr]

represents a button that pastes expr whenever it is pressed.

PasteButton[label,expr]

displays with label on the button.

Details and Options

  • expr is by default pasted at the current insertion point in your input notebook.
  • PasteButton[notebook,label,expr] pastes to the specified notebook.
  • PasteButton evaluates its arguments in an ordinary way, so that expr is immediately evaluated.
  • PasteButton[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 \[SelectionPlaceholder].
  • label can be any expression.
  • PasteButton takes the same options as Button.
  • PasteButton[expr] creates a button with equivalent functionality to the one created by Button[expr,None,BaseStyle->"Paste"].
  • List of all options

Examples

open allclose all

Basic Examples  (3)Summary of the most common use cases

Create a button that will paste its contents:

Out[1]=1

Supply a different label:

Out[1]=1

Create a button to paste an unevaluated expression:

Out[1]=1

Scope  (2)Survey of the scope of standard use cases

PasteButton Content  (1)

Use any expression as a label:

Out[1]=1

PasteButton Control  (1)

Paste the result of an evaluation:

Out[1]=1

Paste a graphics object:

Out[2]=2

Options  (13)Common values & functionality for each option

Alignment  (1)

Different predefined alignment options:

Out[1]=1

Appearance  (1)

Default and "Pressed" appearance:

Out[1]=1

Background  (1)

Change the background colors:

Out[1]=1

BaselinePosition  (1)

Align with the surrounding text:

Out[1]=1

Enabled  (2)

By default PasteButton is enabled:

Out[1]=1

By setting Enabled->False, the button is disabled but visible in its current state:

Out[1]=1

Evaluator  (1)

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

Out[1]=1

FrameMargins  (1)

By setting FrameMargins you make the button content area larger:

Out[1]=1

ImageMargins  (1)

By setting ImageMargins you make the button area larger:

Out[1]=1

ImageSize  (4)

Use preset values:

Out[1]=1

Or use any values:

Out[1]=1

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

Out[1]=1

Set a fully custom size:

Out[1]=1

Applications  (1)Sample problems that can be solved with this function

Make paste buttons for a collection of country strings:

Out[1]=1

Properties & Relations  (2)Properties of the function, and connections to other functions

Use to replace it with the current selection:

Out[1]=1

PasteButton is a special case of Button:

Out[1]=1
Out[2]=2

Possible Issues  (1)Common pitfalls and unexpected behavior

PasteButton does not evaluate its arguments on each click:

Out[1]=1
Wolfram Research (2007), PasteButton, Wolfram Language function, https://reference.wolfram.com/language/ref/PasteButton.html.
Wolfram Research (2007), PasteButton, Wolfram Language function, https://reference.wolfram.com/language/ref/PasteButton.html.

Text

Wolfram Research (2007), PasteButton, Wolfram Language function, https://reference.wolfram.com/language/ref/PasteButton.html.

Wolfram Research (2007), PasteButton, Wolfram Language function, https://reference.wolfram.com/language/ref/PasteButton.html.

CMS

Wolfram Language. 2007. "PasteButton." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PasteButton.html.

Wolfram Language. 2007. "PasteButton." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PasteButton.html.

APA

Wolfram Language. (2007). PasteButton. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PasteButton.html

Wolfram Language. (2007). PasteButton. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PasteButton.html

BibTeX

@misc{reference.wolfram_2024_pastebutton, author="Wolfram Research", title="{PasteButton}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/PasteButton.html}", note=[Accessed: 11-January-2025 ]}

@misc{reference.wolfram_2024_pastebutton, author="Wolfram Research", title="{PasteButton}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/PasteButton.html}", note=[Accessed: 11-January-2025 ]}

BibLaTeX

@online{reference.wolfram_2024_pastebutton, organization={Wolfram Research}, title={PasteButton}, year={2007}, url={https://reference.wolfram.com/language/ref/PasteButton.html}, note=[Accessed: 11-January-2025 ]}

@online{reference.wolfram_2024_pastebutton, organization={Wolfram Research}, title={PasteButton}, year={2007}, url={https://reference.wolfram.com/language/ref/PasteButton.html}, note=[Accessed: 11-January-2025 ]}