Quantcast
WoWInterface - View Single Post - Clear Button Texture and Text LUA Help
View Single Post
04-24-17, 10:12 PM   #7
Dejablue
A Wyrmkin Dreamwalker
 
Dejablue's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 55
Originally Posted by Fizzlemizz View Post
That code doesn't actually do anything because you're checking if a Fontstring you've just created exists, and it always will because, you've just created a new one, along with a new parent button.

if BAG_UPDATE fires a billion times your code will have created a billion new buttons and fontstrings.

Rather than this, you need to check if a button of the same name exists before you create a new one:
Code:
local BMUDButton
if not _G["BMUDButton"..name] then
	BMUDButton = CreateFrame("Button", "BMUDButton"..name, UIParent, "SecureActionButtonTemplate");
	-- Create the extra bits here
else
	BMUDButton = _G["BMUDButton"..name]
	-- reset the extra bits here
end
Wouldn't I want to check if a button exists and then clear it and if it doesn't then create it?

What do I do to reset the buttons? I have tried myriad solutions, none work.


BMUDButton:SetNormalTexture(nil,"ARTWORK")
BMUDButton:SetPushedTexture(nil,"ARTWORK")
BMUDButton:SetHighlightTexture(nil,"ARTWORK")
BMUDButtonFS:SetFormattedText("")
or

Code:
_G["BMUDButton"..name]:SetNormalTexture(nil,"ARTWORK")
_G["BMUDButton"..name]:SetPushedTexture(nil,"ARTWORK")
_G["BMUDButton"..name]:SetHighlightTexture(nil,"ARTWORK")
_G["BMUDButton"..name]:SetFormattedText("")
  Reply With Quote