Skip to content

Instantly share code, notes, and snippets.

@Meorawr
Last active July 17, 2020 22:50
Show Gist options
  • Save Meorawr/5bfc576e7353b41c2bbc61361bbe8df1 to your computer and use it in GitHub Desktop.
Save Meorawr/5bfc576e7353b41c2bbc61361bbe8df1 to your computer and use it in GitHub Desktop.
Parentless Frame Bug (9.x)
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
<!--
Bug #1:
Instantiating a frame ("TestFrame") that has no parent attribute
specified and is hidden upon creation seems to cause some issues
with the visiblity of child frames.
This is quite odd to explain, but running `TestFrame:Show()` ingame
causes only the "MagicTexture" Texture element to appear until the
frame itself is relocated or resized (click to drag), at which point
all child elements suddenly pop into existence.
This can be rectified in one of three ways:
1. If the template itself specifies a <Size> element, the issue
doesn't occur. The instantiated frame defining such an element
has no impact on this.
2. If the instantiated frame is parented to UIParent, the issue
doesn't occur.
3. If the instantiated frame isn't hidden on creation, the issue
doesn't occur.
Bug #2:
Commenting out the "MagicTexture" Texture element entirely will cause
the whole frame to remain invisible when explicitly shown via
`TestFrame:Show()`; child elements will _not_ become visible when
the frame is dragged. This persists also across frame resizes.
This seems to correct itself if you reparent the frame once the
Show method has been called;
TestFrame:Show() - Frame invisible, but is interactable.
TestFrame:SetParent(UIParent) - Frame shows after this point.
TestFrame:SetParent(nil) - Frame remains visible.
On Retail servers, the below all works fine (all child frames are sized
and shown correctly when `TestFrame` is shown).
-->
<Frame name="TestFrameTemplate" virtual="true">
<Frames>
<Frame parentKey="Child" inherits="BackdropTemplate">
<KeyValues>
<KeyValue key="backdropInfo" value="BACKDROP_DIALOG_32_32" type="global"/>
</KeyValues>
<Anchors>
<Anchor point="TOPRIGHT"/>
<Anchor point="BOTTOMLEFT"/>
</Anchors>
<Layers>
<Layer level="BACKGROUND">
<!-- Comment this texture out for bug #2. -->
<Texture parentKey="MagicTexture" file="Interface\Buttons\White8x8">
<Anchors>
<Anchor point="TOPLEFT"/>
<Anchor point="BOTTOMRIGHT"/>
</Anchors>
<Color r="0.5" g="0" b="0.5"/>
</Texture>
</Layer>
</Layers>
<Frames>
<Frame parentKey="Box" inherits="BackdropTemplate">
<KeyValues>
<KeyValue key="backdropInfo" value="BACKDROP_TOAST_12_12" type="global"/>
</KeyValues>
<Anchors>
<Anchor point="TOP"/>
<Anchor point="LEFT"/>
<Anchor point="RIGHT"/>
</Anchors>
<Size x="0" y="65" />
</Frame>
<Button parentKey="Button" inherits="UIPanelButtonTemplate" text="Click me!">
<Anchors>
<Anchor point="BOTTOM"/>
<Anchor point="LEFT"/>
<Anchor point="RIGHT"/>
</Anchors>
<Size x="0" y="65" />
</Button>
</Frames>
</Frame>
</Frames>
</Frame>
<Frame name="TestFrame" hidden="true" inherits="TestFrameTemplate" movable="true">
<Anchors>
<Anchor point="CENTER"/>
</Anchors>
<Size x="360" y="240"/>
<Scripts>
<OnMouseDown method="StartMoving"/>
<OnMouseUp method="StopMovingOrSizing"/>
</Scripts>
</Frame>
</Ui>
@Meorawr
Copy link
Author

Meorawr commented Jul 17, 2020

Screenshot if TestFrame:Show() is executed in the chat frame; note that only the "MagicTexture" (purple color texture) is shown and no children are visible:

WowB_2020-07-17_23-39-08

Screenshot if the frame is moved by dragging it, showing that once any points, size, or parent details are changed all child elements suddenly pop into existence:

WowB_2020-07-17_23-39-14

Screenshot of the frame working fine upon UI load if the hidden="true" attribute is removed:

WowB_2020-07-17_23-39-40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment