On this page:
22.1 Clipboard Operations
clipboard-text
set-clipboard-text!
clipboard-has-text?
9.0.0.11

22 Clipboard🔗ℹ

This section covers system clipboard access.

22.1 Clipboard Operations🔗ℹ

procedure

(clipboard-text)  (or/c string? #f)

Gets text from the system clipboard.

Returns the clipboard text as a string, or #f if the clipboard is empty or doesn’t contain text.

(define text (clipboard-text))
(when text
  (printf "Clipboard contains: ~a~n" text))

procedure

(set-clipboard-text! text)  #t

  text : string?
Sets the system clipboard text.

Returns #t on success.

(set-clipboard-text! "Hello from SDL3!")

procedure

(clipboard-has-text?)  boolean?

Returns #t if the clipboard contains text.

(when (clipboard-has-text?)
  (define text (clipboard-text))
  (handle-paste text))