Thread Tools Display Modes
11-07-21, 03:56 PM   #1
fullmoon_sulfuras
A Fallenroot Satyr
Join Date: Dec 2019
Posts: 21
GameTooltip:GetBackdrop() a nil value for Shadowlands 90105

Hi there! I'm a little baffled by the following line working on Classic, BCc and Restila (up to 90100), but throwing an exception in Retail 90105:


Lua Code:
  1. backdrop = GameTooltip:GetBackdrop();

I get the following exception:

Code:
Interface\AddOns\LunarSphere\lib\moduleButton.lua:223: attempt to call method 'GetBackdrop' (a nil value)
I've searched the GametoolTip API ref and it doesn't seem to have a GetBackdrop method, nor a notice that it has been deprecated.

I've tried using this:

Lua Code:
  1. if not GameTooltip:GetBackdrop then
  2.         Mixin(tooltip, BackdropTemplateMixin)
  3.     end

But then I get an error:

Code:
function arguments expected near 'then'

I'm not the original author of the addon, so I'm not sure what was their intention calling
Code:
GameTooltip:GetBackdrop()
and not over some object (something like
Code:
my_widget:GetBackdrop()
)

Thanks!!

Last edited by fullmoon_sulfuras : 11-07-21 at 04:03 PM.
  Reply With Quote
11-07-21, 08:26 PM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,359
Code:
if not GameTooltip:GetBackdrop then
        Mixin(tooltip, BackdropTemplateMixin)
    end
You probably meant to do this
Code:
if not GameTooltip.GetBackdrop then
  Mixin(GameTooltip, BackdropTemplateMixin)
end
  Reply With Quote
11-08-21, 09:02 AM   #3
fullmoon_sulfuras
A Fallenroot Satyr
Join Date: Dec 2019
Posts: 21
Thanks for the suggestion!

Indeed, the code below works:

Lua Code:
  1. if not GameTooltip.GetBackdrop then
  2.     print("No GetBackdrop")
  3.     Mixin(GameTooltip, BackdropTemplateMixin)
  4. else
  5.     print("GetBackdrop")
  6. end


The Mixin call doesn't really fix the problem, because now I don't get an error for calling a function the doesn't exist (attempt to call method 'GetBackdrop' (a nil value)), but GetBackdrop returns nil on the Retail client (works fine on BCC and Classic)

What I'm curious now is:

1. My understanding is that GameTooltip is a global object created by the API itself. Is this correct?
2. What is the proper fix for my original problem (attempt to call method 'GetBackdrop' (a nil value)), or the second (GetBackdrop returning nil after the Mixin call)?
3. This used to work on 90100. Why is it broken now?
4. The double-colon syntax denotes a class, while the period denotes an object, right (I come from C++)? My understanding is that in Lua they're the same thing as Lua is prototype-based. Why do I have to use a different syntax in the test and in the call?

Thanks!!!

Last edited by fullmoon_sulfuras : 11-08-21 at 09:24 AM.
  Reply With Quote
11-08-21, 10:49 AM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Code:
GameTooltip.NineSlice:GetBackdrop()
Although it's not really going to solve any problems caused by the underlying change.

There is a GameToolTip widget type (like a Frame or a Button widget type) and there is the "GameToolTip" frame (a GameToolTip widget that has been given the name "GameToolTip") that inherits "SharedTooltipTemplate" which has a sub-frame that inherits the "NineSlicePanelTemplate". This is new to 9.1.5.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 11-08-21 at 11:00 AM.
  Reply With Quote
11-11-21, 10:07 PM   #5
fullmoon_sulfuras
A Fallenroot Satyr
Join Date: Dec 2019
Posts: 21
Thanks for the answer. I'm still not sure that the line

Lua Code:
  1. GameTooltip:GetBackdrop()

Is supposed to do. Pardon my ignorance, what's the difference between that call above and

Lua Code:
  1. GameTooltip.GetBackdrop

?
  Reply With Quote
11-11-21, 10:32 PM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
As I believe it's mentioned elsewhere, frames are just special types of tables so:

GameTooltip.GetBackdrop is the same as GameTooltip["GetBackdrop"] ie. test the existance/value of the GetBackdrop key in the GameTooltip table (in this case it's a function (method))

GameTooltip:GetBackdrop() runs the function but unlike using GameTooltip.GetBackdrop(), automatically passes the table (or in this case frame) as the first parameter (self).
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
11-19-21, 06:52 AM   #7
Lybrial
A Flamescale Wyrmkin
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 120
So how can we hide the backdrop of a tooltip now? I used to do:

Lua Code:
  1. _G.GameTooltip:SetBackdrop(nil);
  Reply With Quote
11-19-21, 07:04 AM   #8
Lybrial
A Flamescale Wyrmkin
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 120
Ah!

Lua Code:
  1. _G.GameTooltip.NineSlice:Hide();
  Reply With Quote
12-05-21, 05:42 PM   #9
fullmoon_sulfuras
A Fallenroot Satyr
Join Date: Dec 2019
Posts: 21
Thanks very much for your answers.


There is a GameToolTip widget type (like a Frame or a Button widget type)
OK

and there is the "GameToolTip" frame (a GameToolTip widget that has been given the name "GameToolTip") that inherits "SharedTooltipTemplate" which has a sub-frame that inherits the "NineSlicePanelTemplate". This is new to 9.1.5.
I'm not sure what you wrote that is new. The '"GameToolTip" frame'? Or that it inherits from SharedTooltipTemplate? Or that SharedTooltipTemplate has the subframe?

So, back to my original question. Before 9.1.5, the line

Lua Code:
  1. backdrop = GameTooltip:GetBackdrop();

Would get the backdrop (the default one I presume) from the GameToolTip widget type. Now, it's trying to get the backdrop from the "GameToolTip frame", which doesn't have that method (that would make sense of the `attempt to call method 'GetBackdrop' (a nil value)` error)? If that changed, what's the new equivalent way to get the backdrop?

Thanks very much!
  Reply With Quote
12-05-21, 07:33 PM   #10
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
In 9x frames no longer had a the backdrop system automatically applied to all of them, you had to manually add it to frames that needed a backdrop so Blizz added the system to the GameTooltip.

In 9.1.5 the layout of the GameTooltip frame changed so they can have funkier tooltips. With this change, the backdrop was moved from being applied to the top level frame (GameTooltip) to the NineSlice sub-frame so:

Code:
GameTooltip:GetBackdrop()
changed to:
Code:
GameTooltip.NineSlice:GetBackdrop()
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » GameTooltip:GetBackdrop() a nil value for Shadowlands 90105

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