Chapter 7. Clipboard Support

Because support for the clipboard is essential in any desktop application, AIR allows for access to the operating system clipboard in several data formats. AIR also provides support for many operations beyond the standard copying, cutting, and pasting of text within an application. The standard data formats within AIR let you work with many types of text data, bitmap data, and even file references. Another great feature of the clipboard support within AIR is that you can extend it and create your own custom clipboard data format to fit your AIR application.

Working with the Clipboard Data Types

Problem

You need to be able to see whether a specific type of data is present on the operating system clipboard.

Solution

Use the hasFormat method of the ClipboardFormats class to determine whether the desired format is defined by that class.

Discussion

The clipboard is designed to hold multiple types of data simultaneously. It is often prudent to store multiple formats of the same data when you store to the clipboard, because you may not know the preferred format of the application that may later use the clipboard data. AIR gives you the ability to work with the different data formats via many of the methods of the Clipboard class. To begin with, six default clipboard data formats are defined in AIR:

  • ClipboardFormats.TEXT_FORMAT: This format contains simple text data within the clipboard.

  • ClipboardFormats.HTML_FORMAT: This format contains formatted HTML data within the ...

Get Adobe AIR 1.5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.