DragImage()

Syntax

Result = DragImage(ImageID [, Actions])
Description
Starts a Drag & Drop operation with image data.

Parameters

ImageID The image to drag. ImageID() can be used to get this ID for an image.
Actions (optional) A combination of the Drag & Drop actions that should be allowed for the image. 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 image can be copied
  #PB_Drag_Move: The image can be moved
  #PB_Drag_Link: The image 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 if #PB_Drag_Move is returned, it is your responsibility to remove the dragged image from your application.

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

  ; Drag the image to an application that can accept images like an office or graphic program.
  ;
  If LoadImage(1, #PB_Compiler_Home + "examples/sources/data/PureBasicLogo.bmp")
    If OpenWindow(1, 200, 200, 400, 90, "Drag & Drop", #PB_Window_SystemMenu)
      ImageGadget(1, 10, 10, 380, 70, ImageID(1))
    
      Repeat
        Event = WaitWindowEvent()      
        If Event = #PB_Event_Gadget And EventGadget() = 1 And EventType() = #PB_EventType_DragStart
          DragImage(ImageID(1))
        EndIf      
      Until Event = #PB_Event_CloseWindow
    EndIf
  EndIf

See Also

DragFiles(), DragText(), DragPrivate(), DragOSFormats(), SetDragCallback()

Supported OS

All

<- DragFiles() - DragDrop Index - DragOSFormats() ->