From Xojo Documentation

Revision as of 22:00, 13 August 2021 by Gperlman (talk | contribs) (Notes)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Class (inherits from Object)

Used to read and write information to and from the Clipboard.

Picture Text
Close RawData TextAvailable
PictureAvailable RawDataAvailable


In order to read text from or write text to the Clipboard, you must create an object of type Clipboard and then access the Text or Picture properties of the Clipboard object you create. You can place a picture on the Clipboard by setting the Picture property. You can use the SetText and AddRawData methods to write text or binary data to the Clipboard. The Clipboard class is not available to Console applications.

For best results, create a new Clipboard object each time you need to use the clipboard.

The Clipboard supports UTIs (Uniform Type Identifiers).

For iOS, only Text is currently supported.

Sample Code

This code gets the text on the Clipboard and copies it to a variable:

Var c As New Clipboard
Var s As String
s = c.Text

This code puts text on the Clipboard:

Var c As New Clipboard
c.Text = "The Quick Brown Fox outran the Lazy Dog"

This code checks to see if the Clipboard is text data and if so, copies the contents of the clipboard to a TextField:

Var c As New Clipboard
If c.TextAvailable Then
TextField1.Text = c.Text
End If

This code copies an image to the Clipboard:

Var c As New Clipboard
If ImageWell1.Image <> Nil Then
c.Picture = ImageWell1.Image
MessageBox("No picture is available!")
End If

When you want to put more than one item on the clipboard, you can't use the properties of this class to append new text or graphics to existing material. You need to do the appending in your code and just use one call to the Text property:

Var text1 As String = "This is the first item being put on the clipboard!"
Var text2 As String = "This is the second item being put on the clipboard"
Var c As New Clipboard
c.Text = text1 + text2


Desktop and iOS project types on all desktop, iOS and iPadOS operating systems.