DragFiles()

Syntax

Result = DragFiles(Files$ [, Actions])
Description
Starts a Drag & Drop operation with a list of filenames.

Parameters

Files$ The list of filenames or directories to drag. Multiple filenames should be separated with a Chr(10) (linefeed) character. Each filename must include its full path, as the target application will not know how to resolve relative names. The filenames must refer to existing files, so the target application can access them.
Actions (optional) A combination of the Drag & Drop actions that should be allowed for the files. If the parameter is not specified, #PB_Drag_Copy will be the only allowed action. Possible actions are: (they can be combined with '|')
  #PB_Drag_Copy: The files can be copied
  #PB_Drag_Move: The files can be moved
  #PB_Drag_Link: The files can be linked
The user can decide which of these actions to take by pressing modifier keys like Ctrl or Shift. The actions that can really be taken also depend on the actions allowed by the drop target. (On MacOSX, the actions are only treated as a suggestion. The drop target can still choose another action.)

Return value

Returns one of the above Drag & Drop action values to indicate what action the user took, or #PB_Drag_None if the user aborted the Drag & Drop operation.

Note that unlike with the other functions that start Drag & Drop, nothing should be done when #PB_Drag_Move is returned. As the dragged data is only the filename and not the file itself, any action that is taken on the file must be done by the drag target.

Remarks

Drag & Drop can basically be started any time, but the left mouse button should be currently pressed as otherwise the operation will end immediately without success. The usual time to start a Drag & Drop operation is when a Gadget reported an event with EventType() of #PB_EventType_DragStart.

Example

  ; Select some files or folders and drag them to another application
  ;
  If OpenWindow(1, 200, 200, 400, 400, "Drag & Drop", #PB_Window_SystemMenu)
    ExplorerListGadget(1, 10, 10, 380, 380, "*", #PB_Explorer_MultiSelect)
  
    Repeat
      Event = WaitWindowEvent()  
          
      If Event = #PB_Event_Gadget And EventGadget() = 1 And EventType() = #PB_EventType_DragStart
        Files$ = ""       
        For i = 0 To CountGadgetItems(1)-1
          If GetGadgetItemState(1, i) & #PB_Explorer_Selected
            Files$ + GetGadgetText(1) + GetGadgetItemText(1, i) + Chr(10)
          EndIf
        Next i        
        
        DragFiles(Files$)
      EndIf      
      
    Until Event = #PB_Event_CloseWindow
  EndIf

See Also

DragText(), DragImage(), DragPrivate(), DragOSFormats(), SetDragCallback()

Supported OS

Windows, Linux

DragDrop Index - DragImage() ->