Quantcast Problem setting XML Spell Button Attributes - WoWInterface
Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-19-18, 09:50 AM   #1
nUI Maintainer
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,144
Problem setting XML Spell Button Attributes

I thought this might have been due to the BfA changes, but nope, I can't get this to work in Live.

This is the button frame I am trying to set the attributes for so clicking casts the spell, it is contained within a parent frame, although based on recent code changes I may not need to but that's not the problem
            <Frame parentKey="ButtonFrame" inherits = "XMP_SpellPageTemplate" setAllPoints = "true" hidden = "true">
This is the template for this frame, the buttons will be ultimately hidden by default
    <Frame name = "XMP_SpellPageTemplate" virtual = "true">
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "1" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "2" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "3" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "4" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "5" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "6" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "7" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "8" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "9" />
            <Button inherits = "XMP_SpellButtonTemplate"  hidden = "false" id = "10" />
This is the template for the spell button itself
    <Button name = "XMP_SpellButtonTemplate" inherits = "XMP_IconTemplate,SecureActionButtonTemplate" virtual = "true">
            <Attribute name="type" value="spell" />
            <Attribute name="spell" value="1" type="number" />

            <Cooldown inherits="CooldownFrameTemplate" parentKey="Cooldown" />

And this is my simple icon only button template, that I would hope with the Secure template would allow setting of spell and icon etc.
    <Button name = "XMP_IconTemplate" parentArray = "Buttons" virtual = "true">
        <Size x="40" y="40"/>

            <Layer level="BACKGROUND">
                <Texture parentKey="Icon" setAllPoints = "true"/>

        <NormalTexture parentKey="NormalTexture" file="Interface\Buttons\UI-EmptySlot" setAllPoints = "true"/>
        <PushedTexture parentKey ="PushedTexture" file="Interface\Buttons\CheckButtonHilight" alphaMode = "ADD" setAllPoints = "true"/>
        <HighlightTexture parentKey = "HighlightTexture" file="Interface\Buttons\CheckButtonHilight"  alphaMode = "ADD" setAllPoints = "true"/>  
I then cycle through a list of spells to create icons for ( from my spell ID list ). Setting of the Button will be different depending on the planned placement of the buttons. I noticed 4 different layouts in my situation but again, it's not important. v is the data portion of my spell table and i is the spellID index of the table. portalIdx is set to where this list's portalButton array indexes will start, similarly for teleportIdx. The spell table has the correct information as expected on both live and bfa but on both the spell isn't set ( whether I use spellID or spellName ) nor working.
local Button = v.isPortal and XMP_Main.ButtonFrame.Buttons[portalIdx + v.idx] or XMP_Main.ButtonFrame.Buttons[teleportIdx + v.idx]

My initial addon that I am upgrading was written in pure lua so this worked fine. I noticed that the original code also has the button derive from ActionButtonTemplate, but trying that instead of my own didn't make a difference. Here's my old lua button creation code that works fine.

Lua Code:
  1. local Button = CreateFrame("Button",buttonName,UIParent,"ActionButtonTemplate,SecureActionButtonTemplate")
  2.     Button:SetWidth(36)
  3.     Button:SetHeight(36)
  5.     Button.spellID = spellID
  6.     Button.spellType = spellType
  8.     Button:SetAttribute("type","spell")
  9.     Button:SetAttribute("spell",spellName)
  11.        -- Cooldown creation here  ( not relevant to this problem )
  13.        -- Events Registered for the button here --
  15.        -- OnEvent script set here to execute certain functionality, but no attribute setting so immaterial

I even tried setting a button name up via lua in case that was the reason but nada. Any ideas on what I am missing or misunderstood ? Any help appreciated and tanks in advance.

Last edited by Xrystal : 05-19-18 at 02:18 PM. Reason: Rewording title
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Problem setting XML Spell Button Attributes

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