PluginDragDropped
This member cannot be used in scripts, but is usable in the command bar and plugins.
PluginDragDropped fires when the user releases their mouse over a PluginGui
during a drag operation started by Plugin/StartDrag
.
See also
PluginGui/PluginDragEntered
PluginGui/PluginDragLeft
PluginGui/PluginDragMoved
Parameters
Name | Type | Default | Description |
---|---|---|---|
|
Code Samples
Plugin Drag and Drop
This code sample creates two plugin widget windows: a drag source and a drop target. In the source window, the script creates a TextBox
and TextButton
to allow the user to begin a plugin drag action. The drop target window will display the MimeType of whatever is dragged into it using a TextLabel
. If the MimeType is text/plain, it will display the plain text data instead. Pictured below is an animation of the drag and drop action.
To run this code sample as a plugin, paste it into a Script
. Then, right-click the script in the Explorer window and choose “Save as Local Plugin”.
-- This script must be run as a Studio plugin
assert(plugin)
local widgetInfo = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, true, true, 300, 200)
-- We'll start drags from this widget
local dragSourceWidget = plugin:CreateDockWidgetPluginGui("Drag Source", widgetInfo)
dragSourceWidget.Title = "Drag Source"
-- This TextBox allows the user to type the text to drag
local textBox = Instance.new("TextBox")
textBox.Parent = dragSourceWidget
textBox.Size = UDim2.new(1, 0, 0, 32)
textBox.Text = "Hello, plugin drags"
-- This TextButton will allow the user to start the drag
local dragButton = Instance.new("TextButton")
dragButton.Size = UDim2.new(1,0,1,-32)
dragButton.Position = UDim2.new(0,0,0,32)
dragButton.Text = "Edit the text above, then start drag here"
dragButton.Parent = dragSourceWidget
function onMouseButton1Down()
local dragData = {
Sender = "SomeDragSource";
MimeType = "text/plain";
Data = textBox.Text;
MouseIcon = "";
DragIcon = "";
HotSpot = Vector2.new(0, 0);
}
plugin:StartDrag(dragData)
end
dragButton.MouseButton1Down:connect(onMouseButton1Down)
-- This widget will receive drops
local dragTargetWidget = plugin:CreateDockWidgetPluginGui("Drop Target", widgetInfo)
dragTargetWidget.Title = "Drop Target"
-- This TextLabel will display what was dropped
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.Text = "Drop here..."
textLabel.Parent = dragTargetWidget
local function onDragDrop(dragData)
if dragData.MimeType == "text/plain" then
textLabel.Text = dragData.Data
else
textLabel.Text = dragData.MimeType
end
end
dragTargetWidget.PluginDragDropped:connect(onDragDrop)
dragTargetWidget.PluginDragEntered:connect(function (dragData)
print("PluginDragEntered")
end)
dragTargetWidget.PluginDragLeft:connect(function (dragData)
print("PluginDragLeft")
end)
dragTargetWidget.PluginDragMoved:connect(function (dragData)
print("PluginDragMoved")
end)