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 CeateButton function ie. at the top of the file.