setDragAndDropFiles

setDragAndDropFiles(method: Method);

The setDragAndDropFiles method of the Window class enables files and folders to be dragged and dropped onto a form or control, by establishing the window as an allowed drop target. When files and folders are dropped onto that window or one of its children, JADE calls the method specified in the method parameter, passing the list of files and directories dropped.

It is up to the specified method to process the list of files or directories.

When the user drags the files or folders over the window, Microsoft changes the cursor to a plus (+) symbol in a box, indicating that the window will accept dropped file and folders.

Windows does not allow you to drag and drop files or folders between processes with different levels of administration rights, so this method will therefore not be invoked if it is attempted.

The method passed to the setDragAndDropFiles method must be a method defined on the current form or a method defined on the class of the targeted control (or a superclass of the current form or targeted control).

If the method is defined on the form of the targeted window, the required signature is:

method‑name(win: Window; aray: HugeStringArray);

The win parameter specifies the window on which the files were dropped and the aray parameter specifies an array of file or directory names that were dropped.

If the method is defined on the class of the targeted control targeted, the required signature is:

method‑name(aray: HugeStringArray);

The aray parameter specifies an array of file or directory names that were dropped (self is the control instance on which the files were dropped).

Exception 1000 (Invalid parameter type) occurs if the method:

If the setDragAndDropFiles method is called with a null value in the method parameter, the ability of the window to accept dropped files and directories is cancelled.

You cannot drag and drop files onto external .NET or ActiveX controls using this mechanism.

The following example shows the use of the setDragAndDropFiles method. (As the files are by definition of the client machine, in thin client mode, the files and directories must be accessed using usePresentationClient := true.)

listWilbur1.setDragAndDropFiles(MyForm::acceptFiles);
acceptFiles(dropWindow: Window; nameList: HugeStringArray);
vars
    file   : File;
    folder : FileFolder;
    str    : String;
begin
    create file transient;
    create folder transient;
    foreach str in nameList do
        file.fileName := str;
            // file?
        if file.isAvailable() then
            processDroppedFile(file);
        else
            folder.fileName := str;
            if folder.isAvailable() then
                processDroppedFolder(folder);
            else
                ... invalid entry?
            endif;
        endif;
    endforeach;
epilog
    delete file;
    delete folder;
end;

2016.0.01 and higher