Fandom

WoWWiki

API Frame RegisterForDrag

104,634pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Widget API ← Frame < RegisterForDrag

Registers the object to be draggable by the specified mouse button(s).

obj:RegisterForDrag(mousebuttons);

Arguments
mousebuttons 
The mouse button(s) that can be used to drag the object around the user interface. If no arguments are passed it will disable dragging.

Returns
nil

Example
myAddonFrame:RegisterForDrag("LeftButton");
Result
Would allow the frame named 'myAddonFrame' to be able to be dragged by the user with the left mouse button.
Note: Also makes it so OnMouseUp only fires for those buttons if the cursor is over the frame.

Description
Registers which mouse buttons may be used to drag the object around the user interface.
Use the action self:StartMoving(); in the <OnDragStart> section in your XML to allow the drag action to move your frame. If you're registering from Lua, you can use frame:SetMovable(); frame:SetScript("OnDragStart", frame.StartMoving) to enable a simple drag behavior.

Notes
Subsequent calls to RegisterForDrag() will override rather than augment the current registration. To register for both left and right mouse buttons, for example, use RegisterForDrag("LeftButton","RightButton"), not RegisterForDrag("LeftButton"); RegisterForDrag("RightButton"), which discards the left-button registration.

Also on Fandom

Random Wiki