AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YDAT | YWAIT | Byzgraf | FAQs
Clipboard typedict
 
A Clipboard is the interface to the Java's Clipboard class that can be used to hold a single piece of data which is often loaded using cut-and-paste. Private clipboards can be created and used within an application. The system clipboard, which is available to other applications running on your computer, can be obtained using the getSystemClipboard builtin that is defined in yoix.system. Yoix programs normally interact with a Clipboard using the following fields:
contents A read-only Object that represents the single piece data currently stored in the clipboard. A NULL value means the clipboard is empty. Reading contents is how you recover data from a clipboard. Writing is not currently allowed and will result in an invalidaccess error. For now you must use setContents whenever you want to change contents or owner.
name A String that can be defined when the clipboard is created and used later for identification. There are no requirements that the name be unique, so there is no guarantee that the name will identify a particular clipboard. Writing after the clipboard is created is not allowed and will result in an invalidaccess error.
owner A read-only Object that is the current clipboard owner or NULL, if there is no owner or the actual owner can not be represented by a Yoix Object. Writing is not currently allowed and will result in an invalidaccess error. For now you must use setContents whenever you want to change contents or owner.
setContents(Object data [, Object owner]) A Builtin that stores data in the clipboard, registers owner as the clipboard's owner, and returns 1 if the operation succeeded and 0 if it failed.

The optional owner argument can be NULL or an arbitrary compound object (i.e., any object that associates names with values). owner can define a function named lostClipboardOwnership if it wants to be notified when someone else takes control of the clipboard. lostClipboardOwnership should be declared to take 0, 1, or 2 arguments. The first argument, if there is one, will always be the Clipboard that was affected by the ownership change. The optional second argument should be an Object that will be the data that was stored in the clipboard when the ownership changed.

Several permanent fields have not been documented and should not be used in Yoix applications.
 
 Example:   The program,
import yoix.*.*;

Dictionary d1 = {
    String name = "dictionary 1";

    lostClipboardOwnership(Clipboard arg1, Object arg2) {
        printf("=== %s lost ownership===\n", name);
        printf("   new contents=%O\n", arg1.contents);
        printf("   old contents=%O\n", arg2);
    }
};

Dictionary d2 = {
    String name = "dictionary 2";

    lostClipboardOwnership(Clipboard arg1, Object arg2) {
        printf("=== %s lost ownership===\n", name);
        printf("   new contents=%O\n", arg1.contents);
        printf("   old contents=%O\n", arg2);
    }
};

systemclipboard = getSystemClipboard();

systemclipboard.setContents("testing dictionary d1", d1);
sleep(1);
systemclipboard.setContents("testing dictionary d2", d2);
sleep(1);
systemclipboard.setContents("testing dictionary d1", d1);
sleep(1);
systemclipboard.setContents("testing no owner");
sleep(1);
should print
=== dictionary 1 lost ownership===
   new contents=testing dictionary d2
   old contents=testing dictionary d1
=== dictionary 2 lost ownership===
   new contents=testing dictionary d1
   old contents=testing dictionary d2
=== dictionary 1 lost ownership===
   new contents=testing no owner
   old contents=testing dictionary d1
on standard output.
 
 See Also:   getSystemClipboard

 

Yoix is a registered trademark of AT&T Intellectual Property.