Run when the mouse is dragged starting in the frame. In order for a drag action to begin, the mouse button must be pressed down within the frame and moved more than several (~10) pixels in any direction without being released.
Signature:
OnDragStart(self, "button")
Arguments:
self- Reference to the widget for which the script was run (button)button- Name of the mouse button responsible for the drag action (string)Button4Button5LeftButtonMiddleButtonRightButton
Examples:
-- Illustrates script handlers involved in dragging. Dragging to or
-- from either button will display messages detailing the process.
local nextNum = 1
local last
local handlers = {
"OnMouseDown", "OnMouseUp", "OnDragStart", "OnDragStop", "OnReceiveDrag"
}
local function CreateButton()
local curNum = nextNum
local b = CreateFrame("Button", "Test"..curNum, UIParent, "UIPanelButtonTemplate2")
if curNum == 1 then
b:SetPoint("CENTER")
else
b:SetPoint("LEFT", last, "RIGHT", 5, 0)
end
b:SetText(curNum)
b:RegisterForDrag("LeftButton", "RightButton")
for _, handler in ipairs(handlers) do
b:SetScript(handler, function(self, button)
button = button and ", "..button or ""
DEFAULT_CHAT_FRAME:AddMessage(format("%s: %d%s", handler, curNum, button))
end)
end
nextNum = nextNum + 1
last = b
end
CreateButton()
CreateButton()