Clipboard

From Xojo Documentation

Revision as of 18:55, 19 November 2009 by WikiSysop (talk) (Examples)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Description

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


Super Class

Object

Properties

Name Type Description
Picture Picture The picture on the Clipboard.
PictureAvailable
Boolean Returns True if the Clipboard contains a picture.
Text String The text on the Clipboard.


Methods

Name Parameters Return Type Description
AddRawData
Introduced 2005r1
Data as String,

MacType as String

Copies the passed data to the Clipboard.
Close Closes the Clipboard.

The Clipboard must be closed within the event handler it was opened in or an error will occur.

RawData
Introduced 2005r1
MacType as String String Returns the binary data from the Clipboard as a string for the specified type.
RawDataAvailable
Introduced 2005r1
MacType as String Boolean Returns True if the Clipboard contains data.
SetText Text as String Sets the Clipboard to the text passed.
TextAvailable Boolean Returns True if the data on the Clipboard is text.


Notes

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.


Examples

This example gets the text on the Clipboard and copies it to a variable.

Dim c as New Clipboard
Dim s as String
s=c.text
c.close

This example puts text on the Clipboard.

Dim c as New Clipboard
c.text="The Quick Brown Fox outran the Lazy Dog"
c.close

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

Dim c as New Clipboard
If c.TextAvailable then
TextField1.text=c.Text
End if
c.close

This example copies an image to the Clipboard:

Dim c as New Clipboard
If ImageWell1.image <> Nil then
c.Picture=ImageWell1.image
c.Close
else
MsgBox "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. That is, the following code won't put both text strings on the Clipboard:

Dim c as New Clipboard
c.text="This is the first item being put on the clipboard!"
c.text="This is the second item being put on the clipboard"
c.close

You need to do the appending in your code and just use one call to the Text property.