Class DataTransferItem
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The DataTransferItem object represents one drag data item. During a drag operation, each DragEvent has a DataTransfer property which contains a DataTransferItemList of drag data items. Each item in the list is a DataTransferItem object.
[Value("DataTransferItem")]
public class DataTransferItem
- Inheritance
-
DataTransferItem
- Inherited Members
Remarks
DataTransferItem was primarily designed for the HTML Drag and Drop API, and is still specified in the HTML drag-and-drop section, but it is now also used by other APIs, such as ClipboardData and DataTransfer. Documentation of DataTransferItem will primarily discuss its usage in drag-and-drop operations, and you should refer to the other APIs' documentation for usage of DataTransferItem in those contexts.
This interface has no constructor.
Constructors
DataTransferItem()
public DataTransferItem()
Properties
Kind
The read-only DataTransferItem.kind property returns the kind–a string or a file–of the DataTransferItem object representing the drag data item.
[Value("kind")]
public string Kind { get; }
Property Value
- string
A string representing the drag data item's kind.
It must be one of the following values:
Remarks
Type
The read-only DataTransferItem.type property returns the type (format) of the DataTransferItem object representing the drag data item.
The type is a Unicode string generally given by a MIME type, although a MIME type is not required.
[Value("type")]
public string Type { get; }
Property Value
- string
A string representing the drag data item's type.
Remarks
Methods
GetAsFile()
If the item is a file, the DataTransferItem.getAsFile() method returns the drag data item's File object.
If the item is not a file, this method returns null.
[Value("getAsFile")]
public File? GetAsFile()
Returns
Remarks
GetAsFileSystemHandle()
NOTE
ExperimentalgetAsFileSystemHandle() method of the DataTransferItem interface returns a {{jsxref('Promise')}} that fulfills with a 'FileSystemFileHandle' if the dragged item is a file, or fulfills with a 'FileSystemDirectoryHandle' if the dragged item is a directory.
[Value("getAsFileSystemHandle")]
public Task<FileSystemHandle?> GetAsFileSystemHandle()
Returns
- Task<FileSystemHandle>
A 'Promise'.If the item's Kind property is
"file", and this item is accessed in the HTMLElementdragstart or HTMLElementdrop event handlers, then the returned promise is fulfilled with a 'FileSystemFileHandle' if the dragged item is a file or a 'FileSystemDirectoryHandle' if the dragged item is a directory.Otherwise, the promise fulfills withnull.
Remarks
GetAsString(FunctionStringCallback?)
The DataTransferItem.getAsString() method invokes the given callback with the drag data item's string data as the argument if the item's Kind is a Plain unicode string (i.e., kind is string).
[Value("getAsString")]
public GlobalObject.Undefined GetAsString(FunctionStringCallback? callback)
Parameters
callbackFunctionStringCallback
Returns
Remarks
WebkitGetAsEntry()
If the item described by the DataTransferItem is a file, webkitGetAsEntry() returns a FileSystemFileEntry or FileSystemDirectoryEntry representing it. If the item isn't a file, null is returned.
[Value("webkitGetAsEntry")]
public FileSystemEntry? WebkitGetAsEntry()
Returns
- FileSystemEntry
A FileSystemEntry-based object describing the dropped item.
This will be either FileSystemFileEntry or FileSystemDirectoryEntry.
The method aborts and returnsnullif the dropped item isn't a file, or if the DataTransferItem object is not in read or read/write mode.
Remarks
NOTE
This function is implemented as
webkitGetAsEntry()in non-WebKit browsers including Firefox at this time; it may be renamed togetAsEntry()in the future, so you should code defensively, looking for both.
-File and Directory Entries API
-DataTransferItem
-FileSystemEntry, FileSystemFileEntry, and FileSystemDirectoryEntry
-Events: HTMLElementdragover and HTMLElementdrop