Restoring frame to previous position
1 Attachment(s)
I'm currently working on an addon that tracks the dots on your target.
I can now display both Hemorrhage and Rupture and move the icons around but the problem is that when I /reload or relog the positioning of the frame is reset to the center of the screen. I tried using saved variables but did not manage to get any good results even tho I waited until the ADDON_LOADED event fired to use the variable. I've attached the source code. Attachment 8167 |
There's nothing in your code that would save or restore a position.
The simplest method would be to let the game handle it: Code:
anchor:RegisterForDrag("LeftButton") |
Thanks for the quick reply.
I tried to use the Lua Code:
Quote:
|
The frame needs to have a name, for one. (I didn't check your file) The only time you should need to call SetUserPlaced is when you want to save its position after positioning it with SetPoint.
|
I did give the frame a name, this is how i declared all the frames:
Lua Code:
I will try changing the code a bit when I get home from vacation. I'll keep you updated when I do, thanks for all the help! :) |
Hmm no, the local variable doesn't matter, but frame names are global, and you should absolutely not use such generic names for them. (and not name them at all if avoidable) Use 'DoTrackerFrame' for example. If there's a conflict with some other global variable I guess that might cause a mess. Other than that I'm not sure why it wouldn't work. See if you have an entry for the frame in your layout-cache.txt in the character WTF folder.
|
Ew, don't know how I missed that. Your frame names (the global names passed to CreateFrame, not the local variable names) are so generic it's likely that even if you get everything else working, some other addon (or even the default UI) will leak globals (hopefully accidentally) with the same names, screwing up your addon or vice versa.
Code:
local frame, events = CreateFrame("Frame", "DoTrackerFrame", UIParent), {} |
Just in case. Make sure that when using frame:SetUserPlaced(true) the frame is created when you initialize the addon and not via PLAYER_LOGIN event or the like.
|
Oh, didn't realize that the names where in the global namespace. Will fix this when I get home!
Thanks for all the feedback! :D |
All times are GMT -6. The time now is 12:23 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI