View Single Post
10-07-16, 04:30 AM   #10
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
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)
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-07-16 at 04:40 AM.
  Reply With Quote