The API is no longer being updated here until further notice. |
Registers the frame for dragging with a mouse button.
Frame:RegisterForDrag([button1, ...])
Arguments[]
- button1, ...
- string? :
LeftButton, RightButton, MiddleButton, Button4, Button5
- A list of mouse buttons to drag with.
Details[]
- Pass multiple arguments to register several buttons, or none to remove any previous registrations.
- Subsequent calls replace any prior ones.
- Enables OnDragStart and OnDragStop script handlers.
- Blocks OnMouseUp and OnClick when dragging with a registered button.
Example[]
local f = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
f:SetPoint("CENTER")
f:SetSize(200, 200)
f:SetBackdrop(BACKDROP_TUTORIAL_16_16)
f:SetMovable(true)
f:EnableMouse(true)
f:RegisterForDrag("LeftButton")
f:SetScript("OnDragStart", function(self, button)
self:StartMoving()
print("OnDragStart", button)
end)
f:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
print("OnDragStop")
end)
- Requires calling SetMouseClickEnabled or EnableMouse since this is not automatically implied by OnDragStart
- Requires calling RegisterForDrag