ui.drag(content)

Starts a drag and drop operation.
The function does not return until the user cancels the operation or drops the content.

Notes

  • This method is generally called in an onMouseDown() event.

Parameters

content

Contains the content that will be dragged and dropped, among the following possible values :

  • A string : to drag and drop text data
  • A table : to drag and drop a list of files and directories (using paths as string, File or Directory).

Return value

This function returns a boolean value indicating if the drag and drop operation succeeded (ie the user dropped the content).

Example

local ui = require "ui" local win = ui.Window("ui.drag() sample", "fixed", 320, 300) local lbl = ui.Label(win, "Drag me !") local edit = ui.Edit(win, "") win:status() edit:center() edit.y = 10 lbl:center() lbl.y = edit.y + edit.height + 24 function lbl:onMouseDown() local succeeded = ui.drag("Drag me !") and "succeeded" or "failed" win:status("Drag and drop operation "..succeeded) end ui.run(win):wait()