View Single Post
05-24-21, 08:42 PM   #1
fullmoon_sulfuras
A Fallenroot Satyr
Join Date: Dec 2019
Posts: 21
Problem using a custom backdrop with the new backdrop system changes

Hi there! I'm having a hard time understanding how to translate the old <Backdrop> tags to the new system.

I'm creating the following frame in XML:

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>
This works perfectly. Now I want to customize my backdrop with the following info:

Lua Code:
  1. BACKDROP_TOOLTIP_MYBACKDROP = {
  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. };

I've added that to a .lua file that's listed in the ToC file, and changed my frame to:

Code:
<Frame name="TestFrame" parent="UIParent" inherits="BackdropTemplate">
    <KeyValues>
        <KeyValue key="backdropInfo" value="BACKDROP_TOOLTIP_MYBACKDROP" 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>
The BACKDROP_TOOLTIP_MYBACKDROP is exactly the same as BACKDROP_TOOLTIP_16_16_5555. But now I don't get a frame anymore!

Do I need to place BACKDROP_TOOLTIP_MYBACKDROP somewhere special?

I've also tried to use:

Code:
<Frame name="TestFrame" parent="UIParent">
	<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">
			if BackdropTemplateMixin then -- if this is NOT a Classic type frame, add the backdrop mixin
				Mixin(self, BackdropTemplateMixin)
			end
			self:Setbackdrop( {
				bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
				edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
				tile = true,
				tileEdge = true,
				tileSize = 16,
				edgeSize = 16,
				insets = { left = 5, right = 5, top = 5, bottom = 5 }
			})
			print("Loaded!");
		</OnLoad>
	</Scripts>
</Frame>
But I get an error:

Code:
Message: [string "TestFrame:OnLoad"]:4: attempt to call method 'Setbackdrop' (a nil value)
Time: Mon May 24 22:39:22 2021
Count: 1
Stack: [string "TestFrame:OnLoad"]:4: attempt to call method 'Setbackdrop' (a nil value)
[string "*:OnLoad"]:4: in function <[string "*:OnLoad"]:1>
Thanks!
  Reply With Quote