WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   GameTooltip:GetBackdrop() a nil value for Shadowlands 90105 (https://www.wowinterface.com/forums/showthread.php?t=58974)

fullmoon_sulfuras 11-07-21 03:56 PM

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!!

Dridzt 11-07-21 08:26 PM

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


fullmoon_sulfuras 11-08-21 09:02 AM

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!!!

Fizzlemizz 11-08-21 10:49 AM

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.

fullmoon_sulfuras 11-11-21 10:07 PM

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

?

Fizzlemizz 11-11-21 10:32 PM

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).

Lybrial 11-19-21 06:52 AM

So how can we hide the backdrop of a tooltip now? I used to do:

Lua Code:
  1. _G.GameTooltip:SetBackdrop(nil);

Lybrial 11-19-21 07:04 AM

Ah!

Lua Code:
  1. _G.GameTooltip.NineSlice:Hide();

fullmoon_sulfuras 12-05-21 05:42 PM

Thanks very much for your answers.


Quote:

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

Quote:

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!

Fizzlemizz 12-05-21 07:33 PM

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()


All times are GMT -6. The time now is 11:36 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI