View Single Post
05-30-21, 09:22 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
In every version of the game up to Classic Vanilla, frames were created with a backdrop by default. Since then (Shadowlands/Classic TBC), backdrops are optional and you have to "add" them to your frame(s) if you want one.

This is done by either inheriting the BackdropTemplate when the frame is created or via a Mixin after the frame is created. The template/mixin adds all the regions and methods originaly gained by default like :SetBackdrop(), :SetBackdropColor() etc.

The following allows your code to be use in all versions by detecting if the mixin or one of the backdrop methods exist.

To add on during creation:

Code:
local = CreateFrame("Frame", "name", parent, BackdropTemplateMixin and "BackdropTemplate")
if BackdropTemplateMixin exists then you're playing a version of the game where backdrops are optional so add in the template.

After creation.
Code:
if not frame.SetBackdrop then
    Mixin(frame, BackdropTemplateMixin)
end
Apply the backdrop regions and methods to a frame we want to apply a backdrop too that hasn't already been set up for it ei. do this before frame:SetBackdrop(...).
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 05-30-21 at 01:42 PM.
  Reply With Quote