# copy_selection_to_clipboard

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/clipboard/copy_selection_to_clipboard)

Copy selected text from one screen's widgets to the clipboard.

Selections live on the screen that owns them (`Screen.selections`) and
survive a modal being pushed on top, so a scan has to target exactly one
screen. `screen` is required rather than defaulting to the active screen
because this runs deferred, by which point the active screen may no longer
be the one the caller meant — the caller pins it at event time instead.

## Signature

```python
copy_selection_to_clipboard(
    app: App,
    *,
    screen: Screen,
) -> None
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `app` | `App` | Yes | The active Textual app, used for the clipboard backend and toasts. |
| `screen` | `Screen` | Yes | Screen whose widgets are scanned for selections. |

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/2069079e09546060f5b52b2cd4f0e3c813e820f3/libs/code/deepagents_code/clipboard.py#L145)