Quantcast
WoWInterface - View Single Post - Having issues with secureactionbuttontemplate.
View Single Post
04-12-20, 07:41 PM   #1
timpoole247
A Murloc Raider
Join Date: Apr 2020
Posts: 6
Having issues with secureactionbuttontemplate.

Hi there,

I am currently using the lockdown to finally get round to making my own addon, after 15 years of thinking wouldn't it be nice if I had this addon! Anyway, my experience with Lua is pretty poor, I am reasonably good with basic php so I'm not a complete coding novice.

I am currently making an addon to keep track of my professions on my characters, known patterns, show trainer locations etc etc. So far it has been going well, until I started getting involved with the Enchanting profession! Before I rant on and bore you to death with the details of my struggle, the issue I would like some help with is this; I have a button in my frame which when clicked will open my bags, and cast disenchant. I then discovered its a protected 'spell'. So after doing some googling on the secure template I tried to get it working, but now my button has vanished from the frame. I know the path to my texture works, as it was there before I added the secure template. It could just be weary eyes, but I can't figure out whats wrong with my code.

I would be very grateful is someone could help me with this issue. Here is my code:

Code:
--	Make top frame				
				local topfram = CreateFrame("Frame", "topfram", profra);
				topfram:SetPoint("TOPLEFT", "profra", "TOPLEFT", 5, 0);
				topfram:SetSize(330, 90);
				
--	Make button

				local topframbtn = CreateFrame("Button", "topframbtn", topfram, "SecureActionButtonTemplate");
				topframbtn:SetSize(22, 22);
				topframbtn:SetPoint("TOPLEFT", topfram, "TOPLEFT", 5, -10);
				topframbtn:SetNormalTexture("Interface\\AddOns\\TPPT\\images\\disenchant.blp");
				--topframbtn.bg = topframbtn:CreateTexture(nil, "BACKGROUND")
				--topframbtn.bg:SetAllPoints(true)
				--topframbtn.bg:SetTexture(1, 1, 0, 1);
				
--	Make text

				local toptext = topfram:CreateFontString("toptext", "OVERLAY", "GameFontNormal");
				toptext:SetPoint("TOPLEFT", "topfram", "TOPLEFT", 37, -14);
				toptext:SetText("Disenchant");

--	On click do this
				
				topframbtn:SetAttribute("type", "spell");
				topframbtn:SetAttribute("spell", "disenchant");
				-- topframbtn:SetScript("OnClick", function()
				-- CastSpellByName("disenchant")
				-- OpenAllBags()
				-- end)

Last edited by timpoole247 : 04-13-20 at 07:52 AM. Reason: Updated code
  Reply With Quote