Thread Tools Display Modes
08-28-14, 02:32 PM   #1
zmga
A Murloc Raider
Join Date: Aug 2014
Posts: 5
Problems with Hide() and templates in xml

I'm having an interesting issue with the :Hide() function on my textures. While I am able to show them using texture:Show(), the same texture will return the following error when using texture:Hide()

attempt to call method 'Hide" (a table value)
This problem appears whenever I define my textures in xml with a template


My xml currently follows this kind of logic:

<Texture name="TextureTemplate" virtual="true">
<size, anchors, animations, etc>
</size, anchors, animations, etc>
</Texture>

<Frame name="Myframe">
<Size, Anchors, etc>
</Size, Anchors, etc>
<Layers>
<Layer level="ARTWORK">
<Texture name ="$parent1" file="Interface\AddOns…1" inherits="TextureTemplate"/>
<Texture name ="$parent2" file="Interface\AddOns…2" inherits="TextureTemplate"/>
</Layer>
</Layers>
</Frame>
I assume that defining the texture file in this way is causing the problem but why am I able to show() but not hide()?

How else should I organize my xml so I wouldn't have to repeatedly apply the same animation groups to different texture files?

Last edited by zmga : 08-28-14 at 03:41 PM.
  Reply With Quote
08-28-14, 03:17 PM   #2
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
I've actually never seen someone using templates for textures. Are you sure that this is supported? Or is this just a shot in the dark to see if it's supported?

You could create the textures via lua.

[e]
btw, what does print(type(<yourtextureobject>.Hide)) report?
And /dump <yourtextureobject>.Hide?

Last edited by Duugu : 08-28-14 at 03:21 PM.
  Reply With Quote
08-28-14, 03:33 PM   #3
zmga
A Murloc Raider
Join Date: Aug 2014
Posts: 5
I would assume that it is supported. Blizzard uses texture templates here and there, but not really often enough that I got a clear sense of how it should work.

I based my code on the GlueTemplates.xml and QuestChoice.xml


In the files above they use the template to define the file and assign anchors in the actual texture. I want to do the opposite but this shouldn't make a difference if the template works at all, right?

Maybe there is a gotcha with transferring over names and you need to use relative key.




EDIT: Problem Solved!

It turns out one of my animations had the parentkey Hide. Thanks to Duugu for the help.

Btw does anybody know why this is even a problem? Why does the parent key on an animation override the Hide() command?

Last edited by zmga : 08-28-14 at 03:59 PM.
  Reply With Quote
08-28-14, 04:24 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
My guess would be the "parent" part of parentkey.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
08-28-14, 05:41 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
XML is painfully verbose and ugly, but....

Code:
<Frame name="MyFrame">
     <Frames>
          <Frame parentKey="Hide">
                <!-- some stuff here -->
          </Frame>
     </Frames>
</Frame>
... is the same as doing this:

Code:
CreateFrame("Frame", nil, "MyFrame")
MyFrame.Hide = CreateFrame("Frame")
Hopefully you can see how that would cause problems when attempting to call MyFrame:Hide() !
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-28-14, 07:16 PM   #6
zmga
A Murloc Raider
Join Date: Aug 2014
Posts: 5
Code:
CreateFrame("Frame", nil, "MyFrame")
MyFrame.Hide = CreateFrame("Frame")
Hopefully you can see how that would cause problems when attempting to call MyFrame:Hide() ![/quote]

Sorry, I'm not very versed in lua (or xml for that matter) so more explanation would be helpful. I just assumed that x:hide() was different from x.hide.

Looking it up in the lua wiki it seems that x:hide() is the same thing as x.hide(x) but I'm not quite why that is…
  Reply With Quote
08-28-14, 10:03 PM   #7
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
The colon syntax is used for defining methods, that is, functions that have an implicit extra parameter self. Thus, the statement
function t.a.b.c:f (params) body end
is syntactic sugar for
t.a.b.c.f = function (self, params) body end
Lua 5.1 Reference Manual §2.5.9
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
08-29-14, 12:13 PM   #8
Gethe
RealUI Developer
 
Gethe's Avatar
Premium Member
Featured
Join Date: Sep 2008
Posts: 942
Originally Posted by zmga View Post
Code:
CreateFrame("Frame", nil, "MyFrame")
MyFrame.Hide = CreateFrame("Frame")
Hopefully you can see how that would cause problems when attempting to call MyFrame:Hide() !

Sorry, I'm not very versed in lua (or xml for that matter) so more explanation would be helpful. I just assumed that x:hide() was different from x.hide.

Looking it up in the lua wiki it seems that x:hide() is the same thing as x.hide(x) but I'm not quite why that is…
There was some good discussion about this last week in this thread.
__________________
Knowledge = Power; Be OP

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Problems with Hide() and templates in xml

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