Skip to content

OnFileDropped - DfBaseContainer

Provides a notification that a file drag and drop operation has occurred

Type: Event

Parameters

Parameter Type Description
sFilename String The name of the file being dropped
bLast Boolean True if this is the last file being dropped

Syntax

Procedure OnFileDropped String sFilename Boolean bLast

Description

The OnFileDropped event and the pbAcceptDropFiles property provide a mechanism for supporting file drag and drop within your application.

OnFileDropped is called when a file drag and drop operation has occurred. If multiple files have been dropped, this event will be called once for each file. When the last file has been dropped, the bLast parameter is set to True to indicate that there are no more files to be processed.

The OnFileDropped event is only sent if the container object or one of its parents has pbAcceptDropFiles set to true. The event is sent to the object that has this property set to true.

The following code, when added to your panel object, would demonstrate how file drag and drop works:

Object oMain is a Panel
    :
    Set pbAcceptDropFiles to True

    Procedure OnFileDropped String sFilename Boolean bLast
        Showln "File Drop: " sFileName " " bLast
    End_Procedure
    :

The following example shows how a multiple file drop can be processed:

Object oMain is a Panel
    :
    Property String[] pArrayOfDroppedFiles

    :
    Set pbAcceptDropFiles to True


    Procedure OnFileDropped String sFilename Boolean bLast
        Integer  iFiles
        String[] ArrayOfDroppedFiles EmptyArray

        Get pArrayOfDroppedFiles to ArrayOfDroppedFiles

        // Add the filename to the list of dropped files....
        Move (SizeOfArray(ArrayOfDroppedFiles)) to iFiles
        Move sFilename to ArrayOfDroppedFiles[iFiles] 

        // If this was the last file, process them and clear the list
        If (bLast) Begin
            Send ProcessDroppedFiles ArrayOfDroppedFiles
            // clear the property so it is ready for next drop 
            Move EmptyArray to ArrayOfDroppedFiles
        End

        Set pArrayOfDroppedFiles to ArrayOfDroppedFiles

    End_Procedure
    :
End_Object