View Single Post
09-24-13, 06:53 PM   #20
asett
A Defias Bandit
Join Date: Aug 2013
Posts: 2
Originally Posted by Phanx View Post
There's not really any reason to fake a named template like that anyway, even if it could be done securely. Just write a standard factory function, as shown earlier in the thread.
Agree.
Templates are virtual xml frames and inheriting those frames is just copying their properties and scripts to your frame.
I am using my own function to create frames that allows me to customize my frames just like inheriting xml templates and "templates" are additional lua commands to the newly created frame. When you create "SimpleHTML" frame, you can even specify to automatically add font:

Lua Code:
  1. BuildFrame = function(Frame, Name, parent, xmlVirtualFrame, id, ...)
  2. local frame = CreateFrame(Frame, Name, parent, xmlVirtualFrame, id)
  3.  
  4. if Name == "SimpleHTML" then
  5.     frame:SetFont("Fonts\\FRIZQT__.TTF", 12)
  6. end
  7.  
  8. if tContains({...}, "MyMovingBarTemplate") then -- here you specify your own template
  9. frame:SetSize(self:GetParent():GetWidth(), 15) -- commands to edit your frame, I want to create template of moving bars for my frames
  10. frame:SetPoint("TOPLEFT", self:GetParent(), "TOPLEFT",0,0)
  11. frame:EnableMouse()
  12. frame:RegisterForDrag("LeftButton","RightButton")
  13. frame:SetScript("OnDragStart", function(self) self:GetParent():SetMovable();self:GetParent():StartMoving(); end)
  14. frame:SetScript("OnDragStop", function(self)  self:GetParent():StopMovingOrSizing(); end)
  15. end
  16. if tContains({...}, "MyCloseButtonTemplate") then
  17. -- another commands to edit a frame
  18. end
  19. return frame;
  20. end

I am beginner in lua and xml and I like this more than templates in xml.
You can inherit more than just one template.
  Reply With Quote