AttachCell

AttachCell[expr]

makes expr a cell attached to the current cell being evaluated.

AttachCell[obj,expr]

makes expr a cell attached to the notebook, cell or box object obj.

AttachCell[obj,expr,pos]

specifies that the attached cell should be at position pos relative to obj.

AttachCell[obj,expr,pos,dist]

specifies that the attached cell should be at a distance dist from pos.

AttachCell[obj,expr,pos,dist,opos]

aligns the attached cell so that position opos in expr lies at distance dist from location pos.

AttachCell[cellobj,expr,"Inline"]

specifies that the attached cell should be positioned between the bottom of cellobj and its bottom margin.

Details and Options

  • Attached cells appear only in the current displayed version of a notebook and are not saved with the notebook.
  • AttachCell[obj,] has an effect only while the object obj exists.
  • Attached cells are effectively deployed, and only controls are active in them.
  • AttachCell returns the CellObject of the attached cell if it succeeds, and $Failed otherwise. The resulting attached cell object can be destroyed by calling NotebookDelete on that CellObject.
  • If expr is a raw Cell expression, TextCell or ExpressionCell, then it will be interpreted as a cell of the appropriate type. Any other expression will be treated equivalently to ExpressionCell[expr].
  • obj can be one of the following types of expressions:
  • BoxObject[]attach to the rectangular region occupied by the specified box object; the attached cell scrolls with its parent box
    CellObject[]attach to the rectangular region occupied by the specified cell object; the attached cell scrolls with its parent cell
    NotebookObject[]attach to rectangular region of the notebook window itself; the attached cell remains fixed in the window regardless of scroll position
    NotebookSelection[NotebookObject[]]attach to the rectangular region of the current selection in the notebook; the attached cell remains in that relative position of the document even if the selection later changes
  • Attached cells may be nested by specifying an obj that is an attached cell or is contained within an attached cell.
  • To attach multiple cells to obj, call AttachCell multiple times.
  • The display of an attached cell will typically overlay other content in the parent notebook and will not extend outside the parent notebook's window. If the attachment point scrolls in the notebook, then the attached cell will scroll with it.
  • The position arguments pos and opos can take the following values:
  • Centerthe center
    Leftthe left center
    Rightthe right center
    Topthe top center
    Bottomthe bottom center
    {hor,ver}the horizontal position specified by hor and the vertical position specified by ver
  • The following additional values can be specified for pos:
  • "CellBracket"can be specified by itself or as the horizontal component of pos to attach to a top-level cell's cell bracket
    "Inline"attach below a top-level cell while pushing cells below out of the way
  • The distance dist can be specified by:
  • Automaticpositioned at the perimeter
    Nonepositioned at the center
    dpositioned d units from the perimeter
    Scaled[d]positioned at a scaled distance from the perimeter
    Absolute[d]positioned at an absolute distance from the perimeter
    Offset[{dx,dy},d]positioned at an offset from d
  • AttachCell[obj,expr] is equivalent to AttachCell[obj,expr,{Center,Bottom},Automatic,Automatic].
  • Attached cells inherit formatting from obj in the same way that inline cells do.
  • AttachCell[,RemovalConditions->{cond1,cond2,}] automatically removes the attached cell if any of the conditions condi occur. Possible conditions include:
  • "EvaluatorQuit"default kernel for the cell quits
    "MouseExit"mouse leaves the area
    "MouseClickOutside"click is registered outside of the area
    "ParentChanged"parent object is edited in any way
    "SelectionExit"selection leaves the area
  • Some removal conditions define an area outside of which taking an action will remove the attached cell. The area includes the onscreen space taken by obj and expr. If obj is likewise an attached cell, the area of obj is included. If expr has cells attached to it, the area extends to include all nested attachments.
  • If obj is a top-level cell, then the area includes the cell bracket. A cell insertion point selection immediately below the cell is considered a selection within the area.

Examples

open allclose all

Basic Examples  (4)

Attach a cell containing the given text to the input cell:

Delete the attached cell:

With "Inline" placement, the attached cell pushes other notebook content out of the way:

Display the attached cell on the right edge of the cell it is attached to:

Align the top-right corner of the attached cell with the top of the cell bracket:

Scope  (3)

Use EvaluationBox to attach a cell to a button:

AttachCell can attach a cell to an attached cell:

Deleting an attached cell will also delete any cells attached to it:

Attach a cell to a notebook:

Generalizations & Extensions  (2)

Create an attached cell automatically when a cell is displayed:

Use InheritScope to connect an attached cell's DynamicModule to its attachment's DynamicModule:

Options  (2)

RemovalConditions  (2)

By default, an attached cell will remain for the life of the object it is attached to:

The cell can only be deleted by an operation such as NotebookDelete:

Create an attached cell that closes when you click anywhere outside the attachment:

Create an attached cell that closes when the cell it is attached to is edited:

Properties & Relations  (1)

Attached cells can be found by Cells using AttachedCellTrue:

Interactive Examples  (1)

Attach dynamic content while interacting with a control:

Neat Examples  (2)

Show a custom evaluation indicator near the cell bracket:

Show the progress of an evaluation near the cell bracket:

Wolfram Research (2020), AttachCell, Wolfram Language function, https://reference.wolfram.com/language/ref/AttachCell.html (updated 2024).

Text

Wolfram Research (2020), AttachCell, Wolfram Language function, https://reference.wolfram.com/language/ref/AttachCell.html (updated 2024).

CMS

Wolfram Language. 2020. "AttachCell." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/AttachCell.html.

APA

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

BibTeX

@misc{reference.wolfram_2024_attachcell, author="Wolfram Research", title="{AttachCell}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/AttachCell.html}", note=[Accessed: 03-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_attachcell, organization={Wolfram Research}, title={AttachCell}, year={2024}, url={https://reference.wolfram.com/language/ref/AttachCell.html}, note=[Accessed: 03-December-2024 ]}