WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Tech Chat (https://www.wowinterface.com/forums/forumdisplay.php?f=139)
-   -   Curious, frame won't hide (https://www.wowinterface.com/forums/showthread.php?t=54610)

Fizzlemizz 10-06-16 11:20 PM

Curious, frame won't hide
 
The code below is the only code in an addon I started for a test. The texture is a .blp but setting to a non-existant green square makes no difference.

Does anyone have any idea why this one frame is the only UI element that doesn't hide when I Alt-Z? See.

Code:

local button = CreateFrame("Button", "FauxMazzleAssist")
button:SetSize(21, 21)
button:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -158, 116)
button.Texture = button:CreateTexture("$parentTexture")
button.Texture:SetAllPoints()
button.Texture:SetTexture("Interface/AddOns/FMAssist/MMBG")


Rilgamon 10-07-16 02:53 AM

Probably not parented to UIParent

zork 10-07-16 02:57 AM

^ That is the correct answer
Quote:

CreateFrame("Button", "FauxMazzleAssist", UIParent)

Fizzlemizz 10-07-16 03:11 AM

Seriously? Parent being an optional parameter of CreateFrame (unless I've missed something) should automatically revert to UIParent (nil).

If I'm wrong then just what/who is the parent of a nil declared frame?

zork 10-07-16 03:16 AM

No. You need a lot of event handlers. All of those would rest on UIParent too.

Fizzlemizz 10-07-16 03:40 AM

Alt-Z needs event handlers to hide a frame. My event handlers need to rely on UIParent? I'm getting more confused.

I'm not disrespecting Zork, I'm just not understanding where you're comming from which is probalbly on me.

Fizzlemizz 10-07-16 03:54 AM

I have been schooled. Explitily adding UIParent to the CreateFrame function hdes the frame with Alt-Z.

Thank you to Zork and Rilgamon.

My question now is, who is the parent of a frame without that specific declration?

Rilgamon 10-07-16 04:01 AM

You create it from a template :) So my guess is WorldFrame ... not at home to test it :)

Fizzlemizz 10-07-16 04:09 AM

local button = CreateFrame("Button", "FauxMazzleAssist")

No template involved. Create a "Button" with the name "FauxMazzleAssist".

zork 10-07-16 04:30 AM

Frames without a parent are mostly used for event handling puposes. They need no parent. And if you call frame:GetParent() it wil probably return nothing.

eventHandler
Lua Code:
  1. local eventHandler = CreateFrame("Frame")
  2. eventHandler.OnEvent = function(...)
  3.   print(...)
  4. end
  5. eventHandler:SetScript("OnEvent",eventHandler.OnEvent)
  6. eventHandler:RegisterEvent("PLAYER_LOGIN")

timer
Lua Code:
  1. --only runs if frame is shown
  2. local timer = CreateFrame("Frame")
  3. timer.OnUpdate = function(...)
  4.   print(...)
  5. end
  6. timer:SetScript("OnUpdate",timer.OnUpdate )
  7. timer:Hide()
  8. --to run the timer you show/hide it OnEvent

If you have a frame that should have an visual impact on the game world it has to be part of UIParent (for the sake of ui scaling alone). Some stuff needs to reside on WorldFrame but that is out of my reach. Semlar could probably tell you more. Of course the parent to UIParent is only needed for the first frame of your stack.

frame stack
Lua Code:
  1. local base = CreateFrame("Frame",nil,UIParent)
  2. local level1 = CreateFrame("Frame",nil,base)
  3. local level2 = CreateFrame("Frame",nil,level1)

Fizzlemizz 10-07-16 11:41 AM

The more I think I know, the more it turns out I don't. I was under the assumtion that UIParent was the default.

Thank you both.


All times are GMT -6. The time now is 12:54 AM.

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