From 6a55fc455a76e07fc3253a661f86d2e43afe4c59 Mon Sep 17 00:00:00 2001 From: sindri <33976067+isarsindri@users.noreply.github.com> Date: Mon, 2 Mar 2026 13:27:02 +0100 Subject: [PATCH] Enhance draggable function documentation Added detailed documentation for the draggable function, including options, supported instances, and an example of usage. --- docs/tut/crash-course/12-actions.md | 56 +++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/docs/tut/crash-course/12-actions.md b/docs/tut/crash-course/12-actions.md index e362c63..e4b1318 100644 --- a/docs/tut/crash-course/12-actions.md +++ b/docs/tut/crash-course/12-actions.md @@ -62,3 +62,59 @@ Creates an Action that makes a GuiObject draggable using input events (mouse and ```lua draggable(opts: DraggableOptions?) -> Action + +DraggableOptions + • axis: "x" | "y" | "both" (default "both") +Constrains dragging to a single axis or allows free movement. + • onDragStart: (startPos: UDim2) -> () (optional) +Called when dragging begins. Receives the starting Position. + • onDrag: (newPos: UDim2) -> () (optional) +Called while dragging. Receives the updated Position. + • onDragEnd: (endPos: UDim2) -> () (optional) +Called when dragging ends. Receives the final Position. + +Supported instances + +draggable() must be applied to an instance that: + • is a GuiObject (e.g., Frame, TextButton, ImageLabel, ImageButton), + • has a writable Position property, + • exposes input events such as InputBegan and InputChanged. + +If applied to a non-GuiObject, the Action should be treated as a no-op + +Example: Basic draggable panel +local Players = game:GetService("Players") +local ReplicatedStorage = game:GetService("ReplicatedStorage") + +local vide = require(ReplicatedStorage:WaitForChild("vide")) +local create = vide.create +local mount = vide.mount + +local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui") + +local function App() + return create "ScreenGui" { + Name = "DraggableExample", + ResetOnSpawn = false, + Parent = playerGui, + + create "Frame" { + Position = UDim2.fromOffset(200, 150), + Size = UDim2.fromOffset(420, 240), + BackgroundTransparency = 0.1, + + create "UICorner" { CornerRadius = UDim.new(0, 16) }, + + vide.draggable(), -- defaults to axis = "both" + + create "TextLabel" { + BackgroundTransparency = 1, + Size = UDim2.fromOffset(420, 50), + Text = "Drag this panel", + TextSize = 20, + }, + } + } +end + +mount(App, playerGui)