Retrieves an System.Shell.Item from the Items collection that represents the object(s) dropped on a gadget during a drag-and-drop operation (copying or moving).
Syntax
oItem = System.Shell.itemFromFileDrop(oEvent, intIndex)
Parameters
| oEvent |
Required.
object that specifies the event.dataTransfer object.
|
| intIndex |
Required.
Integer that specifies the index of the System.Shell.Item of interest in the Items collection.
|
Return Value
System.Shell.Item object that represents the specified item, or null if the item cannot be determined.
Remarks
To enable listening for the drag and drop event, both ondragenter and ondragover events must be disabled in the <body> tag of the gadget HTML file (see example).
Example
The following example demonstrates how to display the names of files dropped on the gadget.
<!-- Gadget HTML file. -->
<body onload="Init();"
ondragenter="event.returnValue = false"
ondragover="event.returnValue = false"
ondrop="GetItemFromDrop()">
<div id="gadgetContent">
<span id="spFeedback">Nothing to report.</span>
</div>
</body>
</html>
<!-- Gadget script file. -->
// --------------------------------------------------------------------
// Display the names of objects dropped on the gadget.
// --------------------------------------------------------------------
function GetItemFromDrop()
{
spFeedback.innerHTML = "File(s) dropped.<br/>";
var intIndex = 0;
var oItem;
while(oItem = System.Shell.itemFromFileDrop(event.dataTransfer, intIndex))
{
// Display the current item property and increment the index.
spFeedback.innerHTML += oItem.name + "<br/>";
intIndex++;
}
}
Applies To
See Also
System.Shell.Drive