Thread Tools Display Modes
04-12-20, 07:41 PM   #1
timpoole247
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2020
Posts: 7
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
04-12-20, 09:47 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Set the button NormalTexture rather than creating a separate icon texture.

This sets it to the standard bag icon.

Code:
btn:SetNormalTexture("Interface/Buttons/Button-Backpack-Up");

-- local icon = btn:CreateTexture(nil, "BACKGROUND");
-- icon:SetAllPoints(true);
-- icon:SetTexture("Interface\\AddOns\\TPPT\\images\\disenchant.blp");
-- icon:SetTexture("Interface/Buttons/Button-Backpack-Up");
-- btn.Texture = icon;
If you can't see the button I would look at the frame supplied as the parent to topfram, "profra" and see where that one has been anchored (and any others that might be further up the chain to the topmost frame which is presumably UIParent)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 04-12-20 at 10:02 PM.
  Reply With Quote
04-13-20, 05:49 AM   #3
timpoole247
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2020
Posts: 7
It made no difference, apart from making my code shorter and cleaner, which I am grateful for showing me a better way of doing it.

I believe the issue is definitely related to the secure template. If I remove the reference to the template, the button displays correctly. When using framestack the button and all parents are anchored correctly. As soon as I set the secure template, the button vanishes, the parent frame to the button remains visible.

I tried removing the texture and using a solid colour background instead, again no button with the same results from framestack.
  Reply With Quote
04-13-20, 06:25 AM   #4
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
Using secure template doesn't mean you can use features like CastSpellByName, the template handle the OnClick for you, so you can only set attributes on the button.

For simple, we can bind the macro to the button:

Lua Code:
  1. btn:SetAttribute("type", "macro")
  2. btn:SetAttribute("macrotext", "/cast disenchant\n/run OpenAllBags()")
  Reply With Quote
04-13-20, 07:09 AM   #5
timpoole247
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2020
Posts: 7
Well according to https://wowwiki.fandom.com/wiki/Secu...ButtonTemplate it is possible. I realise I hadn't commented out my old onclick function, (which is how I discovered disenchant was protected) but the execution of the button isn't my issue. I just can't see the button when using the secure template.
  Reply With Quote
04-13-20, 08:11 AM   #6
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Hmm, I'm not 100% sure, but I thought I found that the new SecureActionButtonTemplate isn't a visual template just handles the secure elements.

You would have to add in the visual elements or combine it with a visual template.

Granted the following is an XML version but the same thing should apply when creating by code.

Lua Code:
  1. <!-- Buttons that have textures  -->
  2.     <Button name = "XMP_IconTemplate" parentArray = "Buttons" virtual = "true">
  3.         <Size x="30" y="30"/>
  4.         <Layers>
  5.             <Layer level="BACKGROUND">
  6.                 <Texture parentKey="Icon" setAllPoints = "true"/>
  7.             </Layer>
  8.         </Layers>
  9.         <NormalTexture parentKey="NormalTexture" file="Interface\Buttons\UI-EmptySlot" setAllPoints = "true"/>
  10.         <PushedTexture parentKey ="PushedTexture" file="Interface\Buttons\CheckButtonHilight" alphaMode = "ADD" setAllPoints = "true"/>
  11.         <HighlightTexture parentKey = "HighlightTexture" file="Interface\Buttons\CheckButtonHilight"  alphaMode = "ADD" setAllPoints = "true"/>  
  12.     </Button>
  13.  
  14.     <!-- Buttons used to cast spells -->
  15.     <Button name = "XMP_SpellButtonTemplate" inherits = "XMP_IconTemplate,SecureActionButtonTemplate" virtual = "true">
  16.         <Attributes>
  17.             <Attribute name="type" value="spell" />
  18.             <Attribute name="spell" value="0" type="number" />
  19.         </Attributes>
  20.         <Frames>
  21.             <Cooldown inherits="CooldownFrameTemplate" parentKey="Cooldown" />
  22.         </Frames>
  23.     </Button>

As you can see by this my spell button is actually a combination of an icon button template and the secureactionbuttontemplate

As you can see from this link the secureactionbuttontemplate only handles the onclick event
https://www.townlong-yak.com/framexm...eTemplates.xml

So, moving from your old button template to the new button template you have inadvertently removed the visual functionality of the button.

This is a collection of Blizzards ActionButtonTemplates.
https://www.townlong-yak.com/framexm...onTemplate.xml

As you can see these don't have any onclick functionality as Blizzard has separated them.
__________________
  Reply With Quote
04-13-20, 08:13 AM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Originally Posted by timpoole247 View Post
Well according to https://wowwiki.fandom.com/wiki/Secu...ButtonTemplate it is possible. I realise I hadn't commented out my old onclick function, (which is how I discovered disenchant was protected) but the execution of the button isn't my issue. I just can't see the button when using the secure template.
And for future reference. this is the new info page for wow api information. The other is no longer updated and will likely contain out of date functionality.

https://wow.gamepedia.com/Wowpedia
__________________
  Reply With Quote
04-13-20, 08:34 AM   #8
timpoole247
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2020
Posts: 7
Originally Posted by Xrystal View Post
And for future reference. this is the new info page for wow api information. The other is no longer updated and will likely contain out of date functionality.

https://wow.gamepedia.com/Wowpedia
Awesome, thankyou very much.

I have also just solved my issue too; InsecureActionButtonTemplate rather than SecureActionButtonTemplate.

6 hours of trying different things for the sake of 2 letters.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Having issues with secureactionbuttontemplate.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off