Thread Tools Display Modes
03-01-08, 02:45 PM   #1
Dreadlorde
A Pyroguard Emberseer
 
Dreadlorde's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 2,302
Showing/Hiding frames

I'm trying to hide and show some art based one whether DUF_FocusFrame and DUF_TargetOfTargetFrame is visible. The first thing I could think of was the following code.
Code:
local UrkFocus = CreateFrame("Frame",UrkFocus,UIParent)
UrkFocus:SetFrameStrata("BACKGROUND")
UrkFocus:SetWidth(341.5)
UrkFocus:SetHeight(341.5)

local o = UrkFocus:CreateTexture(UrkFocus,"LOW")
o:SetTexture("Interface\\AddOns\\Urk\\Custom\\focus.tga")
o:SetAllPoints(UrkFocus)
UrkFocus.texture = o

UrkFocus:SetPoint("BOTTOM",100,13)
UrkFocus:Show()

local UrkTot = CreateFrame("Frame",urkTot,UIParent)
UrkTot:SetFrameStrata("BACKGROUND")
UrkTot:SetWidth(341.5)
UrkTot:SetHeight(341.5)

local p = UrkTot:CreateTexture(Urk,"LOW")
p:SetTexture("Interface\\AddOns\\Urk\\Custom\\tot.tga")
p:SetAllPoints(UrkTot)
UrkTot.texture = p

UrkTot:SetPoint("BOTTOM",-100,13)
UrkTot:Show()

--toggle arts
function UrkFocus_Toggle()
   if ( DUF_FocusFrame:IsShown() ) then
      UrkFocus:Show();
   else
      UrkFocus:Hide();
   end
end

function UrkTot_Toggle()
   if ( DUF_TargetOfTargetFrame:IsShown() ) then
      UrkTot:Show();
   else
      UrkTot:Hide();
   end
end
The problem is, this doesn't work; and I was hoping someone could help me figure out how to do it.

Thanks for any help.
__________________

Funtoo - Plan 9 - Windows 7
  Reply With Quote
03-01-08, 04:13 PM   #2
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
you could set it as a parent to the other frames in CreateFrame or use onshow/onhide handlers.

for parenting replace

Code:
local UrkFocus = CreateFrame("Frame",UrkFocus,UIParent)
with

Code:
local UrkFocus = CreateFrame("Frame",UrkFocus,DUF_FocusFrame)
or with the onhide/onshow approach which is slighly more complex do

Code:
local onshow = DUF_FocusFrame:GetScript("OnShow")
DUF_FocusFrame:SetScript("OnShow", function(...)
   UrkFocus:Show()
   return onshow(...)
end

local onhide = DUF_FocusFrame:GetScript("OnHide")
DUF_FocusFrame:SetScript("OnHide", function(...)
   UrkFocus:Hide()
   return onhide(...)
end)
should work.
  Reply With Quote
03-01-08, 07:48 PM   #3
Dreadlorde
A Pyroguard Emberseer
 
Dreadlorde's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 2,302
I get the following error when I use the OnHide/OnShow approach:
Code:
Interface\AddOns\Urk\Core.lua:231: ')' expected (to close '(' at line 226) near 'local'
Line 226 is:
Code:
DUF_FocusFrame:SetScript("OnShow", function(...)
I can't figure out how to fix this either..
__________________

Funtoo - Plan 9 - Windows 7
  Reply With Quote
03-02-08, 02:14 AM   #4
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
I missed a ")" at the end of the onshow function. It should be this

Code:
DUF_FocusFrame:SetScript("OnShow", function(...)
   UrkFocus:Show()
   return onshow(...)
end)
  Reply With Quote
03-02-08, 10:12 AM   #5
Dreadlorde
A Pyroguard Emberseer
 
Dreadlorde's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 2,302
Doh! I think I tried adding ) everywhere but there.

Thanks Slakah.
__________________

Funtoo - Plan 9 - Windows 7
  Reply With Quote
03-02-08, 10:24 AM   #6
erica647
A Cobalt Mageweaver
 
erica647's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 209
Hey Dreadlorde... not sure what editor you use but you might wanna check out Komodo editor. It will highlight syntax errors and may find little things like that for you.

http://www.activestate.com/Products/komodo_edit/
__________________
Karadra
Level 80 Human Deathknight
Silvermoon/Nerfed Guild
  Reply With Quote
03-02-08, 10:33 AM   #7
Dreadlorde
A Pyroguard Emberseer
 
Dreadlorde's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 2,302
I've been using notepad++, but komodo looks nice. I'll try it out.

Thanks for showing me that erica.
__________________

Funtoo - Plan 9 - Windows 7
  Reply With Quote
03-02-08, 10:40 AM   #8
Tristanian
Andúril
Premium Member
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 279
Originally Posted by Dreadlorde View Post
I'm trying to hide and show some art based one whether DUF_FocusFrame and DUF_TargetOfTargetFrame is visible. The first thing I could think of was the following code.
Code:
local UrkFocus = CreateFrame("Frame",UrkFocus,UIParent)
UrkFocus:SetFrameStrata("BACKGROUND")
UrkFocus:SetWidth(341.5)
UrkFocus:SetHeight(341.5)

local o = UrkFocus:CreateTexture(UrkFocus,"LOW")
o:SetTexture("Interface\\AddOns\\Urk\\Custom\\focus.tga")
o:SetAllPoints(UrkFocus)
UrkFocus.texture = o

UrkFocus:SetPoint("BOTTOM",100,13)
UrkFocus:Show()

local UrkTot = CreateFrame("Frame",urkTot,UIParent)
UrkTot:SetFrameStrata("BACKGROUND")
UrkTot:SetWidth(341.5)
UrkTot:SetHeight(341.5)

local p = UrkTot:CreateTexture(Urk,"LOW")
p:SetTexture("Interface\\AddOns\\Urk\\Custom\\tot.tga")
p:SetAllPoints(UrkTot)
UrkTot.texture = p

UrkTot:SetPoint("BOTTOM",-100,13)
UrkTot:Show()

--toggle arts
function UrkFocus_Toggle()
   if ( DUF_FocusFrame:IsShown() ) then
      UrkFocus:Show();
   else
      UrkFocus:Hide();
   end
end

function UrkTot_Toggle()
   if ( DUF_TargetOfTargetFrame:IsShown() ) then
      UrkTot:Show();
   else
      UrkTot:Hide();
   end
end
The problem is, this doesn't work; and I was hoping someone could help me figure out how to do it.

Thanks for any help.
You can try using IsVisible() methods instead of IsShown for UrkFocus_Toggle and UrkTot_Toggle. Just because an object is shown, doesn't necessarily imply it's also visible. It depends on the parents as well.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Showing/Hiding frames


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