View Single Post
05-24-21, 08:17 PM   #6
fullmoon_sulfuras
A Fallenroot Satyr
Join Date: Dec 2019
Posts: 21
Originally Posted by Fizzlemizz View Post
This would mean you are calling frame:SetBackdropColor(...) on a frame that doesn't the mixin set. Maybe a frame created using CreateFrame() with a template that doesn't set a backdrop by default?
The problem goes away if I explicitly inherit from BackdropTemplate. So I'm guessing that
Code:
Mixin(self, BackdropTemplateMixin)
Would fix that. To be clear: the error is thrown in the line

Lua Code:
  1. tempObject = CreateFrame("Frame", objectName, objectParent, "LunarWindow");

So it's not another frame, it's the frame template that I just changed in the XML file.

Originally Posted by Fizzlemizz View Post
Or possibly inheriting a custom xml template that is still using the <Backdrop> </Backdrop> tags and not checking the mixin.

You could
Code:
if not frame.SetBackdropColor then
   Mixin(frame, BackdropTemplateMixin)
end
Sorry, not following here. This works:

Lua Code:
  1. <OnLoad inherit="prepend">
  2.     if BackdropTemplateMixin then
  3.         Mixin(self, BackdropTemplateMixin)
  4.     end
  5.     self:SetBackdropColor(0.2,0.2,0.2,1.0);
  6. </OnLoad>

This does not work (`attempt to call method 'Setbackdrop' (a nil value)` is thrown).

Lua Code:
  1. <OnLoad inherit="prepend">
  2.     if BackdropTemplateMixin then
  3.         Mixin(self, BackdropTemplateMixin)
  4.     end
  5.     self:Setbackdrop( {
  6.         bgFile = "Interface\\AddOns\\LunarSphere\\art\\Window-Background",
  7.         edgeFile = "Interface\\Addons\\LunarSphere\\art\\Window-Border",
  8.         tile = true,
  9.         tileEdge = false,
  10.         tileSize = 128,
  11.         edgeSize = 16,
  12.         insets = { left = 5, right = 5, top = 5, bottom = 5 }
  13.     } )
  14.     self:SetBackdropColor(1.0,1.0,1.0,1);
  15. </OnLoad>

Originally Posted by Fizzlemizz View Post
Prikor to the call, but it seems you would be better figuring our where the backdrop is actually set in the first place and fixing that. Setting the colour of a non-existant backdrop doesn't seem very usefull .
The backdrop is being set in the XML, as per the original post. With the Backdrop System Changes it doesn't work anymore.

A question:

According to the backdrop changes page:

Code:
<KeyValue key="backdropInfo" value="BACKDROP_TOOLTIP_16_16_5555" type="global"/>
Where exactly I need to define the backdropInfo value? I've tried creating a frame with

Code:
<Frame name="TestFrame" parent="UIParent" inherits="BackdropTemplate">
    <KeyValues>
        <KeyValue key="backdropInfo" value="BACKDROP_TOOLTIP_16_16_5555" type="global"/>
        <KeyValue key="backdropBorderColor" value="LEGENDARY_ORANGE_COLOR" type="global"/>
        <KeyValue key="backdropBorderColorAlpha" value="0.25" type="number"/>
    </KeyValues>
    <Size x="300" y="300"/>
    <Anchors>
        <Anchor point="CENTER"/>
    </Anchors>
    <Scripts>
        <OnLoad inherit="prepend">
            print("Loaded!");
        </OnLoad>
    </Scripts>
</Frame>
And it of course works. Now, if I change the backdropInfo line to

Code:
        <KeyValue key="backdropInfo" value="my_backdrop_value" type="global"/>
And define my_backdrop_value in a .lua file:

Lua Code:
  1. my_backdrop_value= {
  2.     bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
  3.     edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
  4.     tile = true,
  5.     tileEdge = true,
  6.     tileSize = 16,
  7.     edgeSize = 16,
  8.     insets = { left = 5, right = 5, top = 5, bottom = 5 },
  9. };

It just doesn't work. Do I need to place it somewhere special?

Thanks!
  Reply With Quote