Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
Advertisement

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)

See also[]

Advertisement