View Single Post
02-12-16, 05:36 PM   #20
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,327
Originally Posted by Fizzlemizz View Post
You don't want to actually drag the buttons themselves, you want to activate the container frame onDragxxx

Code:
            
btn:RegisterForDrag("LeftButton");--    Register for left drag
btn:SetScript("OnDragStart", function(self) 
	local f = frame:GetScript("OnDragStart") -- Get the frame OnDragStart script
	f(frame) -- run it
end);
btn:SetScript("OnDragStop", function(self) 
	local f = frame:GetScript("OnDragStop") -- Get the frame OnDragStop script
	f(frame) -- run it
end);
This requires that the frame creation be above the CreateButton function ie. at the top of the file.
The code I proposed actually is dragging the container frame by calling self:GetParent():StartMoving(). This doesn't require the container frame to be pre-defined since it's accessing it through the button's set parent.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 02-12-16 at 05:55 PM.
  Reply With Quote