EnableGadgetDrop(#Gadget, Format, Actions [, PrivateType])
Enables a gadget to be a target for Drag & Drop operations of a specific format. When the user drags data of this format over the gadget, the cursor will indicate that the data can be dropped there.


#Gadget The PureBasic gadget number for the gadget in question.
Format The data format, which can be one of the following values, or an OS specific ID for a custom format (see DragOSFormats() for more information).
  #PB_Drop_Text   : Accept text on this gadget
  #PB_Drop_Image  : Accept images on this gadget
  #PB_Drop_Files  : Accept filenames on this gadget
  #PB_Drop_Private: Accept a "private" Drag & Drop on this gadget
Actions A combination of the Drag & Drop actions that should be allowed for the data. 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 drag source. Possible actions are: (they can be combined with '|')
  #PB_Drag_None: The data format will not be accepted on the gadget
  #PB_Drag_Copy: The data can be copied
  #PB_Drag_Move: The data can be moved
  #PB_Drag_Link: The data can be linked
PrivateType (optional) The type of private Drag & Drop to accept if 'Format' is #PB_Drop_Private. See DragPrivate() for more information. This parameter is ignored for other formats.

Return value



Multiple formats can be allowed on the same gadget. If the drag source provides multiple formats that match the list of accepted formats, the one that was added last will be accepted. So the preferred format in which to receive data should be enabled last.

If data was dropped on the gadget, the program will receive a #PB_Event_GadgetDrop event. EventGadget() will indicate the target gadget and the Event functions of this library can be used to get the dropped data.


  ; Drag a file to one of the gadets and you will receive the file path
  If OpenWindow(0, 0, 0, 500, 200, "Drop File Here", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    StringGadget(0, 10, 10, 500 - 20, 30, "")
    EditorGadget(1, 10, 50, 500 - 20, 140)
    EnableGadgetDrop(0, #PB_Drop_Files, #PB_Drag_Copy)
    EnableGadgetDrop(1, #PB_Drop_Files, #PB_Drag_Copy)
        Select WaitWindowEvent()
            Case #PB_Event_GadgetDrop
                Select EventGadget()
                    Case 0 ; gadgets that received a file/folder drag and drop event
                        If Not FindString(EventDropFiles(), Chr(10))
                            SetGadgetText(0, EventDropFiles())
                    Case 1
                        SetGadgetText(1, EventDropFiles())
            Case #PB_Event_CloseWindow

See Also

EnableWindowDrop(), EventDropType(), EventDropAction(), SetDropCallback()

Supported OS


<- DragText() - DragDrop Index - EnableWindowDrop() ->