Advertisement
Guest User

Untitled

a guest
Jan 25th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 6.18 KB | None | 0 0
  1. package openfl.desktop; #if (display || !flash)
  2.  
  3.  
  4. import openfl.utils.Object;
  5.  
  6. @:jsRequire("openfl/desktop/Clipboard", "default")
  7.  
  8.  
  9. /**
  10.  * The Clipboard class provides a container for transferring data and objects
  11.  * through the clipboard. The operating system clipboard can be accessed
  12.  * through the static <code>generalClipboard</code> property.
  13.  *
  14.  * <p>A Clipboard object can contain the same information in more than one
  15.  * format. By supplying information in multiple formats, you increase the
  16.  * chances that another application will be able to use that information. Add
  17.  * data to a Clipboard object with the <code>setData()</code> or
  18.  * <code>setDataHandler()</code> method.</p>
  19.  *
  20.  * <p>The standard formats are:</p>
  21.  *
  22.  * <ul>
  23.  *   <li>BITMAP_FORMAT: a BitmapData object (AIR only)</li>
  24.  *   <li>FILE_LIST_FORMAT: an array of File objects (AIR only)</li>
  25.  *   <li>HTML_FORMAT: HTML-formatted string data</li>
  26.  *   <li>TEXT_FORMAT: string data</li>
  27.  *   <li>RICH_TEXT_FORMAT: a ByteArray containing Rich Text Format data</li>
  28.  *   <li>URL_FORMAT: a URL string (AIR only)</li>
  29.  * </ul>
  30.  *
  31.  * <p>These constants for the names of the standard formats are defined in the
  32.  * ClipboardFormats class.</p>
  33.  *
  34.  * <p>When a transfer to or from the operating system occurs, the standard
  35.  * formats are automatically translated between ActionScript data types and
  36.  * the native operating system clipboard types.</p>
  37.  *
  38.  * <p>You can use application-defined formats to add ActionScript objects to a
  39.  * Clipboard object. If an object is serializable, both a reference and a
  40.  * clone of the object can be made available. Object references are valid only
  41.  * within the originating application.</p>
  42.  *
  43.  * <p>When it is computationally expensive to convert the information to be
  44.  * transferred into a particular format, you can supply the name of a function
  45.  * that performs the conversion. The function is called if and only if that
  46.  * format is read by the receiving component or application. Add a deferred
  47.  * rendering function to a Clipboard object with the
  48.  * <code>setDataHandler()</code> method. Note that in some cases, the
  49.  * operating system calls the function before a drop occurs. For example, when
  50.  * you use a handler function to provide the data for a file dragged from an
  51.  * AIR application to the file system, the operating system calls the data
  52.  * handler function as soon as the drag gesture leaves the AIR
  53.  * application—typically resulting in an undesireable pause as the file data
  54.  * is downloaded or created.</p>
  55.  *
  56.  * <p><b>Note for AIR applications:</b> The clipboard object referenced by the
  57.  * event objects dispatched for HTML drag-and-drop and copy-and-paste events
  58.  * are not the same type as the AIR Clipboard object. The JavaScript clipboard
  59.  * object is described in the AIR developer's guide.</p>
  60.  *
  61.  * <p><b>Note for Flash Player applications:</b> In Flash Player 10, a paste
  62.  * operation from the clipboard first requires a user event (such as a
  63.  * keyboard shortcut for the Paste command or a mouse click on the Paste
  64.  * command in a context menu). <code>Clipboard.getData()</code> will return
  65.  * the contents of the clipboard only if the InteractiveObject has received
  66.  * and is acting on a paste event. Calling <code>Clipboard.getData()</code>
  67.  * under any other circumstances will be unsuccessful. The same restriction
  68.  * applies in AIR for content outside the application sandbox.</p>
  69.  *
  70.  * <p>On Linux, clipboard data does not persist when an AIR application
  71.  * closes.</p>
  72.  */
  73. extern class Clipboard {
  74.    
  75.    
  76.  
  77.     /**
  78.      * The operating system clipboard.
  79.      *
  80.      * <p>Any data pasted to the system clipboard is available to other
  81.      * applications. This may include insecure remote code running in a web
  82.      * browser.</p>
  83.      *
  84.      * <p><b>Note:</b> In Flash Player 10 applications, a paste operation from
  85.      * the clipboard first requires a user event (such as a keyboard shortcut
  86.      * for the Paste command or a mouse click on the Paste command in a
  87.      * context menu). <code>Clipboard.getData()</code> will return the
  88.      * contents of the clipboard only if the InteractiveObject has received
  89.      * and is acting on a paste event. Calling
  90.      * <code>Clipboard.getData()</code> under any other circumstances will be
  91.      * unsuccessful. The same restriction applies in AIR for content outside
  92.      * the application sandbox.</p>
  93.      *
  94.      * <p>The <code>generalClipboard</code> object is created automatically.
  95.      * You cannot assign another instance of a Clipboard to this property.
  96.      * Instead, you use the <code>getData()</code> and <code>setData()</code>
  97.      * methods to read and write data to the existing object.</p>
  98.      *
  99.      * <p>You should always clear the clipboard before writing new data to it
  100.      * to ensure that old data in all formats is erased.</p>
  101.      *
  102.      * <p>The <code>generalClipboard</code> object cannot be passed to the AIR
  103.      * NativeDragManager. Create a new Clipboard object for native
  104.      * drag-and-drop operations in an AIR application.</p>
  105.      */
  106.     public static var generalClipboard (default, null):Clipboard;
  107.    
  108.  
  109.     /**
  110.      * An array of strings containing the names of the data formats available
  111.      * in this Clipboard object.
  112.      *
  113.      * <p>String constants for the names of the standard formats are defined
  114.      * in the ClipboardFormats class. Other, application-defined, strings may
  115.      * also be used as format names to transfer data as an object.</p>
  116.      */
  117.     public var formats (get, never):Array<ClipboardFormats>;
  118.    
  119.     @:noCompletion private function get_formats ():Array<ClipboardFormats>;
  120.    
  121.     public function clear ():Void;
  122.     public function clearData (format:ClipboardFormats):Void;
  123.     public function getData (format:ClipboardFormats, transferMode:ClipboardTransferMode = null):Object;
  124.     public function hasFormat (format:ClipboardFormats):Bool;
  125.     public function setData (format:ClipboardFormats, data:Object, serializable:Bool = true):Bool;
  126.     public function setDataHandler (format:ClipboardFormats, handler:Void->Dynamic, serializable:Bool = true):Bool;
  127.    
  128.    
  129. }
  130.  
  131.  
  132. #else
  133. typedef Clipboard = flash.desktop.Clipboard;
  134. #end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement