Object:SetParentKey

From Warcraft Wiki
Jump to navigation Jump to search

Sets a key on the parent to the child object.

Object:SetParentKey(parentKey [, clearOtherKeys])

Arguments

parentKey
string
clearOtherKeys
boolean? - If true, clear all fields on the parent object that currently reference this child object.

Details

  • This is similar to the XML parentKey attribute.

Example

Sets a hello key on the parent object.

local parent = CreateFrame("Frame")
local f = CreateFrame("Frame", nil, parent)

-- this is equivalent
--f:GetParent().hello = f
f:SetParentKey("hello")

Creates a texture and sets it as a shroom key on the parent object.

local f = CreateFrame("Frame", nil, UIParent)
f:SetPoint("CENTER")
f:SetSize(64, 64)

-- this is equivalent
--f.shroom = f:CreateTexture()
f:CreateTexture():SetParentKey("shroom")

f.shroom:SetAllPoints(f)
f.shroom:SetTexture("interface/icons/inv_mushroom_11")

Patch changes

Dragonflight Patch 10.2.0 (2023-11-07): Added clearOtherKeys parameter in hotfix build 52095 on Nov 8 2023. For the duration of 10.2 prior to this build, this function would unconditionally act as if this parameter had been set to true.
Dragonflight Patch 10.0.0 (2022-10-25): Added.