Wikia

WoWWiki

API Frame RegisterForDrag

Talk0
102,281pages on
this wiki

Redirected from API RegisterForDrag

Widget API


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.

Around Wikia's network

Random Wiki