Is there currently a way to programmatically copy a line of text to your PC's clipboard? (equivalent of CTRL+C)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Tybobobo
:warning: Old Version Published before Godot 3 was released.

Is there currently a way to copy a string to your PC’s clipboard from code?
(equivalent of CTRL+C and having some text stored for later being able to paste somewhere)

I wish to create a button that allows to user to copy to clipboard without having to select the text and copy it themselves.

:bust_in_silhouette: Reply From: Bojidar Marinov

Isn’t OS.set_clipboard(string) exactly what you want?
Also, string OS.get_clipboard() does the opposite operation :-).

Perfect, thank you :slight_smile:

Tybobobo | 2016-10-21 15:52

:bust_in_silhouette: Reply From: popcar2

In Godot 4, it’s now DisplayServer.clipboard_set(string)