Why frame never attaches to UIParent?
Hi,
I have the following code: Lua Code:
What it should do: It should create a frame and attach that frame to the UIParent by default. But when the player nameplate is getting added AND when im not in combat the frame should get attached to the personal player resources. What it does: It never attaches to the UI Parent. When im in combat and I hide and show the UI again the print method tells me that the "Detach" was called but still the frame is getting anchored to the nameplate. I dont get how this is possible. It is always attaching to the nameplate even though the print method tells me the "Detach" method is getting called. Anyone an idea why this is happening? |
I haven't tested this but ...
Shouldn't it be: Code:
print("attach: " .. (self.anchorFrame:GetParent()):GetName()); Code:
print("detach: " .. (self.anchorFrame:GetParent()):GetName()); |
Name doesnt matter. I just wanted to make sure that "Detach" is getting called.
But yes, If I would want to output the parent frame you would be right. Code:
print("detach: " .. (self:GetParent()):GetName()) Still all frames are still attached to nameplate and not UIParent. |
Oh, right, I see your point now.
Still, on a second look at your code, you are passing self as argument to self.anchorFrame.Attach(self) and to self.anchorFrame.Detach(self). You then call frame methods on self that I believe you want to be called on self.anchorFrame instead. I'm unsure about this, but that may be the problem. If I'm right, the easy fix would be to use self.anchorFrame as prefix to :SetParent, etc. |
In this case self is the anchorFrame :)
Look what happens if I add some outputs to Detach function: Lua Code:
output: Code:
Detach called |
You are right and I would agree the output of your prints does not make sense.
That is actually why I went ahead and guessed at the possibility that the use of the reserved word "self" as a parent table to the frame itself might be causing a problem. In other words, I understood the logic of your use of "self" and it is correct AFAIK, but there have been times where the WoW API seems to contradict Lua logic (maybe I just don't get it but... recently I got a C_Stack_Overflow on a semi-personal addon of mine (and I couldn't figure out why); come Blizzard's latest hotfixes and the error was gone!). Getting back to your case, have you tried :SetParent(nil) before setting a new parent? I know, should not be needed, but... |
To my knowledge one of the more recent updates included a change to anchoring, including Nameplates. With it came the change that you can only anchor children of a Nameplate to the plate itself or one of its other children.
Blue post summary: Quote:
|
And that happens even if you clearAllPoints() Oo
God I hate these 8.2 changes, seriously.... |
And in the light of jeruku's post, I winged up an addon with your (slightly edited) code and my previous suggestion does work. I.e.:
Lua Code:
Code:
Detach called Furthermore, :GetPoint should be added to the list jeruku quoted under "The following APIs are now blocked from being called on restricted frames:" If you add thiese two lines to the end of the snippet above: Lua Code:
Code:
Detach called Code:
Message: Interface\AddOns\alkaTestLyabral\alkaTestLyabral.lua:22: Action[FrameMeasurement] failed because[Can't measure restricted regions]: attempted from: LybrialUIAnchor:GetPoint(). Finally, I also created a texture on the frame. And it's weird. The texture reportedly attaches correctly to the frame, wich on Detach is reportedly positioned at "CENTER, UIParent, CENTER, 0, -150". Code: Lua Code:
Code:
Detach called I'm actually rather unfamiliar with working with textures, so I may be missing something. For reference, here's the full code I ran: Lua Code:
I'll be going back to my own nerve-wrecking projects now. But if anyone has any more insight on any of this, I'd be curious. And... happy coding, Lybrial! |
All times are GMT -6. The time now is 10:54 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI