Originally Posted by Fizzlemizz
I missed the CreateFrame code for btn in the original post
For Blizz to save the position, the frame has to have a unique name.
Lua Code:
local btn = CreateFrame("Button", addonName.."MovingButton", UIParent, "UIPanelButtonTemplate")
|
And it didn't work again. The button after
/reload returned to the center
Lua Code:
local btn = CreateFrame("Button", addonName.."MovingButton", UIParent, "UIPanelButtonTemplate")
btn:SetPoint("CENTER")
btn:SetSize(100, 40)
btn:SetText("Click me")
btn:SetScript("OnClick", function(self, button, ...)
btn:SetMovable(true)
btn:RegisterForDrag('LeftButton')
btn:SetUserPlaced(true) -- Only works if the frame is created before the PLAYER_LOGIN event
btn:SetScript('OnDragStart', btn.StartMoving)
btn:SetScript('OnDragStop', btn.StopMovingOrSizing)
if (button == "RightButton" and btn:IsVisible()) then
btn:Hide()
end
updateData()
updateList()
f:Show()
end)
btn:RegisterForClicks("AnyUp")