|Type||Cut, copy and paste|
Live Clipboard is an extensible data format and set of UI technologies used to support copy/paste operations between web applications in browsers, and between web and desktop applications. Unlike the typical copy/paste experience in browsers, the Live Clipboard mechanism never needs to display a security dialog to the end user, thus delivering a more streamlined user experience.
DHTML technical introduction
The Live Clipboard DHTML provides copy/paste functionality for data associated with a web page using the Live Clipboard XML data format. It consists of the following components:
- UI elements for displaying the Live Clipboard icon
How it works
The control positions a transparent (opacity = 0) input element in a containing
div element with a background .png image of the clipboard icon. When the user gives focus to the input by left- or right-clicking it, tabbing etc. the control script gets the data that should be copied by calling the OnGetLiveClipboardData function. This callback function is implemented by the page developer and returns an instance of LiveClipboardClass containing the data that should be copied to the clipboard. Next, the control script serializes this data to the Live Clipboard XML format, which it sets as the value of the input element and selects.
At this point, if the user issues a "copy" command via the context menu, browser edit menu, ctrl-C command etc., the selected contents of the input are put on the clipboard. Alternately, if the user issues a "paste" command, the value of the input is replaced with the current data on the clipboard. In this case, the control script detects that the input value has changed, de-serializes the value from Live Clipboard XML format to an instance of LiveClipboardClass, and passes the object to the OnHandleLiveClipboardData function.
The paste callback function is implemented by the page developer and responds to the pasted data as desired. Specifically, it might iterate through the present data formats, apply data in any recognized format(s) to the page, make an asynchronous call to the web server to persist state, set up a new feed subscription, etc. It is also valid to do nothing, such as when none of the formats in the pasted data are valid for the associated data.
There are mechanisms to use keyboard events to trigger copy/paste. This is accomplished by calling the InitiateKeyboardCopyToLiveClipboard and InitiateKeyboardPasteFromLiveClipboard functions.