SecureActionButtonTemplate type="flyout" throws an error

Hello,

I’m kinda trying to understand how the SecureActionButtonTemplate works.
I have a Button that inherits this Template in my XML :

<Button name="OldSpellButtonTemplate" inherits="SecureActionButtonTemplate" virtual="true">
	<Size>
		<AbsDimension x="37" y="37" />
	</Size>
	[...]
</Button>

And Buttons that inherits this newly created template :

<Button name="OldSpellButton1"
	inherits="OldSpellButtonTemplate" id="1">
	<Anchors>
		<Anchor point="TOPLEFT">
			<Offset>
				<AbsDimension x="34" y="-85" />
			</Offset>
		</Anchor>
	</Anchors>
</Button>

And in the Lua, if the spell is a flyoutSpell, I change the button type attribute to a flyout.

if spellData.spellType == Enum.SpellBookItemType.Flyout then
    -- Show flyout arrow
    if flyoutArrow then
        flyoutArrow:Show()
    end

    -- Set sub-spell string to indicate it's a Flyout spell
    subSpellString:SetText("Flyout")
    subSpellString:Show()

    -- Securely handle the flyout toggle
    self:SetAttribute("type", "flyout")
    self:SetAttribute("flyout", spellID)
    self:SetAttribute("flyoutDirection", "RIGHT") 

else

Yes, spellID in this case is a flyoutID, I checked. When I parse spells, I do something like this :

 spellID = flyoutID or spellInfo.spellID or spellInfo.actionID, 

And I checked at runtime, when I run GetFlyoutInfo, I get all info without any problems. But, for the love of god, why do I have this error that appears when I click on any Button that is a flyout?

Blizzard_ActionBar/Mainline/SpellFlyout.lua:225: Usage: name, description, numSlots, isKnown = GetFlyoutInfo(flyoutID)
[string "=[C]"]: in function 'GetFlyoutInfo'
[string "@Blizzard_ActionBar/Mainline/SpellFlyout.lua"]:225: in function 'Toggle'
[string "@Blizzard_FrameXML/Mainline/SecureTemplates.lua"]:368: in function 'handler'
[string "@Blizzard_FrameXML/Mainline/SecureTemplates.lua"]:667: in function <...ddOns/Blizzard_FrameXML/Mainline/SecureTemplates.lua:649>
[string "@Blizzard_FrameXML/Mainline/SecureTemplates.lua"]:681: in function <...ddOns/Blizzard_FrameXML/Mainline/SecureTemplates.lua:674>
[string "@Blizzard_FrameXML/Mainline/SecureTemplates.lua"]:723: in function <...ddOns/Blizzard_FrameXML/Mainline/SecureTemplates.lua:707>
Locals:
(*temporary) = nil

I’m currently lost.

Edit: To be noted, all type="spell" Buttons are working great. So in this case, the SecureActionButtonTemplate is working fine.

Should be
self:SetAttribute("spell", spellID)
https://warcraft.wiki.gg/wiki/SecureActionButtonTemplate

You’re a lifesaver. Now that I re-read the documentation, it makes sense. I thought you needed to set the flyout attribute, but no, it was spell. Thank you.

Any way you can help me understand why, now, it gives me this new error?

9x ...eBlizzard_ActionBar/Mainline/SpellFlyout.lua:241: attempt to index field 'bar' (a nil value)
[string "@Blizzard_ActionBar/Mainline/SpellFlyout.lua"]:241: in function `Toggle'
[string "@OldSpellBook/OldSpellBookFrame.lua"]:513: in function <OldSpellBook/OldSpellBookFrame.lua:508>

Locals:
self = SpellFlyout {
 isActionBar = true
 eventsRegistered = false
 Background = Frame {
 }
}
flyoutID = 224
parent = OldSpellButton10 {
}
direction = "RIGHT"
distance = 0
isActionBar = true
specID = nil
showFullTooltip = nil
reason = nil
offSpec = nil
oldParent = nil
oldIsActionBar = nil
_ = "Voie héroïque : Legion"
_ = "Téléporte à l’entrée d’un donjon de Legion pour lequel vous avez obtenu le haut fait Héros ou Héroïne mythique. Le temps de recharge de ces sorts se réinitialise lorsque vous terminez un donjon en mode Clé mythique."
numSlots = 6
isKnown = true
(*temporary) = nil
(*temporary) = nil
(*temporary) = SpellFlyout {
 isActionBar = true
 eventsRegistered = false
 Background = Frame {
 }
}
(*temporary) = OldSpellButton10 {
}
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = "attempt to index field 'bar' (a nil value)"
SPELLFLYOUT_DEFAULT_SPACING = 4
SPELLFLYOUT_INITIAL_SPACING = 7

What’s line 508 & 513 of OldSpellBook\OldSpellBookFrame.lua

Sorry for the late reply.

This is what’s strange. Sometimes, the line numbers don’t point to anything useful.
In this case, I’m going to show you line 484 to 526:

484:     if spellData.spellType == Enum.SpellBookItemType.Flyout then
485:         -- Show flyout arrow
486:         if flyoutArrow then
487:             flyoutArrow:Show()
488:         end
489: 
490:         -- Set sub-spell string to indicate it's a Flyout spell
491:         subSpellString:SetText("Flyout")
492:         subSpellString:Show()
493: 
494:         -- Securely handle the flyout toggle
495:         self:SetAttribute("type", "flyout")
496:         self:SetAttribute("spell", spellID)
497:         self:SetAttribute("flyoutDirection", "RIGHT")
498: 
499:     else
500:         -- Regular spell handling
501:         self:SetAttribute("type", "spell")
502:         self:SetAttribute("spell", spellID)
503: 
504:         -- Hide the flyout arrow if it exists
505:         if flyoutArrow then
506:             flyoutArrow:Hide()
507:         end
508: 
509:         -- Set the sub-spell string for passive or regular spells
510:         subSpellString:SetText(spellData.isPassive and "Passive" or "")
511:         subSpellString:Show()
512: 
513:         -- Set desaturation for unlearned or off-spec spells
514:         if spellData.isOffSpec or spellData.spellType == Enum.SpellBookItemType.FutureSpell then
515:             iconTexture:SetDesaturated(true)
516:         else
517:             iconTexture:SetDesaturated(false)
518:         end
519:     end
520: 
521:     -- Ensure the selection state is updated
522:     OldSpellButton_UpdateSelection(self)
523: 
524:     -- Finally, show the button
525:     self:Show()
526: end

I should add that this Button is not on an Action Bar. It’s in the SpellBook. So the fact that it thinks it is may be the problem, but I haven’t found how to set isActionBar to false in any way.

Hmmm not sure. Looking at the source
https://github.com/Gethe/wow-ui-source/blob/live/Interface/AddOns/Blizzard_ActionBar/Mainline/SpellFlyout.lua#L241
it appears that it’s looking for a bar that the button’s on.

From the dump

isActionBar = true

So if you can change that to false it might help things.

I posted this to the NA forums and they’ve made some observations

Thank you!
I’ve read the wow-ui-source github already and seen that isActionBar is defined inside the function activating the flyout. So I can’t really pre-set it.
But those answers on the US forum are interesting! I’ll look into it.
Thanks again for your time. It was a great help!

The “problem” is in this template.

The function definition for the Flyout Toggle is as follow : SpellFlyout_Toggle(self, flyoutID, parent, direction, distance, isActionBar, specID, showFullTooltip, reason))
When you go to line 339, you can see SpellFlyout:Toggle(flyoutId, self, direction, 0, true);, with a “isActionBar” set to “true” by default.

So if you use a SecureActionButtonTemplate, you cannot, in today’s UI, use the flyout action without having the spell on an Action Bar.

This issue is still discussed on the WoWUIBugs github here.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.