Talk:UIOBJECT Texture

From Warcraft Wiki
Jump to navigation Jump to search

Textures and SetParent

It is claimed that "[Textures] cannot be reassigned from one frame to another".
However, textures inherit SetParent from Region, and calling SetPoint updates the texture's position, so this claim seems false.
Luovako (talk) 16:50, 27 December 2020 (UTC)

I'm not sure I understand what "reassigned" means here. To be honest, I just copypasted it from https://wowprogramming.com/docs/widgets/Texture.html. At least reparenting works fine for me, if you mean that. Ketho (talk) 03:52, 3 January 2021 (UTC)
local f = CreateFrame("Frame", "TestFrame", UIParent)
f:SetPoint("CENTER", -100, 0)
f:SetSize(64, 64)

local g = CreateFrame("Frame", "OtherFrame", UIParent)
g:SetPoint("CENTER", 100, 0)
g:SetSize(64, 64)

SomeTex = f:CreateTexture()
SomeTex:SetAllPoints(f)
SomeTex:SetTexture("interface/icons/inv_mushroom_11")

-- /run SomeTex:SetParent(OtherFrame) -- parented to other frame
-- /run TestFrame:Hide() -- doesnt hide the texture once reparented
-- /run OtherFrame:Hide() -- hides the texture once parented
-- /dump TestFrame:GetRegions() -- returns nil once parented
-- /dump OtherFrame:GetRegions() -- returns the texture once parented