Originally Posted by Lombra
That's because once you start dragging it, it clears all points and positions it relative to the UIParent. (or maybe its own parent, not sure)
Can you post some more code? Can't really tell what's going on from little bits of information here and there. I don't really understand what the exact issue is from the original post. I gather that there is some undesired positioning.
Frames that have a name will have their position automatically saved in layout-cache. (a file in the WTF folder that saves frame positions and dimensions) These values then get loaded and applied at some point in the loading process. (probably after ADDON_LOADED, maybe before PLAYER_LOGIN) This may override or conflict with any anchor points you want to explicitly set yourself. Doing frame:SetDontSavePosition(true) ensures that the frame will not be saved in layout-cache. Other than that it's hard to tell.
|
I managed to do some reading before you posted this, so I now know a lot more about how frames behave when moving them. As a result, it turns out I left an important piece of information out that the objects I was moving were children of a frame that contains them all (in the circumstance where the user would want to move all the objects at once, instead of one at a time).
Thankfully, however, I found someone who ran into the same issue that I did and provided a great fix that seems to be working
Lua Code:
Object:SetScript("OnMouseDown",function(self)
local framePt,_,parentPt,x,y = self:GetPoint(1)
self.framePt = framePt
self.parentPt = parentPt
self.frameX = x
self.frameY = y
self:StartMoving()
-- once it has done so, we need the starting offset relative to UIParent
-- so we can determine later what the relative movement was
_,_,_,x,y = self:GetPoint(1)
self.screenX = x
self.screenY = y
end);
Object:SetScript("OnMouseUp",function(self)
local framePt,_,parentPt,x,y = self:GetPoint(1)
self:StopMovingOrSizing()
-- once we have it, subtract the starting screen-offset to get the delta,
-- and then add that to the starting frame-offset to get a new frame-offset
x = (x - self.screenX) + self.frameX
y = (y - self.screenY) + self.frameY
self:ClearAllPoints()
self:SetPoint(self.framePt, self:GetParent(), self.parentPt, x, y)
-- and finally, clean up
self.framePt = nil
self.parentPt = nil
self.frameX = nil
self.frameY =nil
self.screenX = nil
self.screenY = nil
end);
Original thread that I found the solution:
https://forums.wowace.com/showthread.php?t=15268
Thank you all for all of your assistance