Hello,
I'm sure everybody is familiar with making a frame movable and saving its position by doing something like this:
Lua Code:
frame:SetScript("OnMouseDown", function()
if not frame.isMoving then
frame:StartMoving()
frame.isMoving = true
end
end)
frame:SetScript("OnMouseUp", function()
if frame.isMoving then
frame:StopMovingOrSizing()
frame.isMoving = false
MyAddon.db.profile.position = {frame:GetPoint()}
end
end)
Now I'm doing this for numerous frames, so I'm trying to make a function out of it:
Lua Code:
function MyAddon:SetupDrag(frame, dbsetting)
frame:SetScript("OnMouseDown", function()
if not frame.isMoving then
frame:StartMoving()
frame.isMoving = true
end
end)
frame:SetScript("OnMouseUp", function()
if frame.isMoving then
frame:StopMovingOrSizing()
frame.isMoving = false
-- Parameters get passed as values, so this won't work
-- dbsetting = {frame:GetPoint()}
-- This works
dbsetting[1], dbsetting[2], dbsetting[3], dbsetting[4], dbsetting[5] = frame:GetPoint()
end
end)
end
And example function call:
MyAddon:SetupDrag(ExampleFame, MyAddon.db.profile.position)
This works a little. Once I reset or change Ace profiles, it stops functioning. I think after the profile changes, MyAddon.db.profile.position will reference properly, but dbsetting will not?
Can't figure out a fix for that. Any ideas?