-
Posted by mgersting on Tue, 21 Apr 2009 02:03:26
I'm dynamically making buttons:
function MakeButton(player_name)
button_name = player_name .. "_Button"
button = CreateFrame("Button",button_name,...)
end
These buttons extend a template that has a FontString which named "$parentPlayerName", such that essential it becomes named player_namePlayerName.
Assuming the player's named is "Dude" I could then set the text like so:
Dude_ButtonPlayerName:SetText("whatever I want")
However, without knowing what the player's name is going to be, how I can then access this text item?
-
Posted by jnwhiteh on Tue, 21 Apr 2009 03:54:02
I'm dynamically making buttons:
function MakeButton(player_name)
button_name = player_name .. "_Button"
button = CreateFrame("Button",button_name,...)
end
These buttons extend a template that has a FontString which named "$parentPlayerName", such that essential it becomes named player_namePlayerName.
Assuming the player's named is "Dude" I could then set the text like so:
Dude_ButtonPlayerName:SetText("whatever I want")
However, without knowing what the player's name is going to be, how I can then access this text item?
-
Posted by jnwhiteh on Tue, 21 Apr 2009 03:55:51
I'm dynamically making buttons:
function MakeButton(player_name)
button_name = player_name .. "_Button"
button = CreateFrame("Button",button_name,...)
end
These buttons extend a template that has a FontString which named "$parentPlayerName", such that essential it becomes named player_namePlayerName.
Assuming the player's named is "Dude" I could then set the text like so:
Dude_ButtonPlayerName:SetText("whatever I want")
However, without knowing what the player's name is going to be, how I can then access this text item?
You can look it up dynamically using the name:
_G[self:GetName() .. "PlayerName"]:SetText("FOO")
Alternatively, you could set a parentKey attribute on the button (like parentKey="playerName"). Then you can access it directly by using self.playerName.
-
Posted by mgersting on Tue, 21 Apr 2009 08:37:17
I apologize - I'm running out the door and haven't tested either, but I'm curious: in my instance would
self:GetName() be button:GetName()
-
Posted by jnwhiteh on Tue, 21 Apr 2009 12:28:25
yes.