WoW:API CreateFrame: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
Line 16: Line 16:


:;newFrame : Frame - Pointer to the newly created frame.
:;newFrame : Frame - Pointer to the newly created frame.


== Example ==  
== Example ==  
Line 32: Line 31:
  f:SetPoint("CENTER",0,0)
  f:SetPoint("CENTER",0,0)
  f:Show()
  f:Show()


== Notes ==
== Notes ==
* CreateFrame() was added in 1.10
* CreateFrame() was added in 1.10
* The fourth argument, inheritFrame, was added in 1.11
* The fourth argument, inheritFrame, was added in 1.11
* In creating frames with CreateFrame(), you cannot use the OnLoad script handler (e.g. Frame:SetScript("OnLoad", ''function'')) since CreateFrame() loads the frame before Frame:SetScript() is called. If you want to use the OnLoad script handler, define the frame in an XML file that is called before the LUA file or call the OnLoad function manually at the end of the LUA file.
* In creating frames with CreateFrame(), you cannot use the OnLoad script handler (e.g. Frame:SetScript("OnLoad", ''function'')) since CreateFrame() loads the frame before Frame:SetScript() is called. If you want to use the OnLoad script handler, define the frame in an XML file that is called before the LUA file or call the OnLoad function manually at the end of the LUA file.
*: ''Considering that the developer is creating the frames with lua, there is not much point in a handler that runs an lua function when the frame is loaded... the developer can just run their code in the lua file that's creating the frame immediatly after they create the frame!''

Revision as of 08:51, 18 July 2007

WoW API < CreateFrame

Creates a new UI frame.

newFrame = CreateFrame("frameType", "frameName", parentFrame[, "inheritsFrame"]);

Parameters

Arguments

frameType
String - Type of the frame to be created (XML tag name): "Frame", "Button"... etc.
frameName
String - Name of the newly created frame. If nil, no frame name is assigned. Function will also set a global variable of this name to point to newly created frame.
parentFrame
Frame - The frame object that will be used as the created Frame's parent (cannot be a string!)
inheritsFrame
String - Name of a (virtual) frame to inherit (the same as in XML)

Returns

newFrame
Frame - Pointer to the newly created frame.

Example

Result: displays the horde and alliance insignias in the middle of the screen.

local f = CreateFrame("Frame",nil,UIParent)
f:SetFrameStrata("BACKGROUND")
f:SetWidth(128)  -- Set These to whatever height/width is needed 
f:SetHeight(64) -- for your Texture

local t = f:CreateTexture(nil,"BACKGROUND")
t:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Factions.blp")
t:SetAllPoints(f)
f.texture = t

f:SetPoint("CENTER",0,0)
f:Show()

Notes

  • CreateFrame() was added in 1.10
  • The fourth argument, inheritFrame, was added in 1.11
  • In creating frames with CreateFrame(), you cannot use the OnLoad script handler (e.g. Frame:SetScript("OnLoad", function)) since CreateFrame() loads the frame before Frame:SetScript() is called. If you want to use the OnLoad script handler, define the frame in an XML file that is called before the LUA file or call the OnLoad function manually at the end of the LUA file.
    Considering that the developer is creating the frames with lua, there is not much point in a handler that runs an lua function when the frame is loaded... the developer can just run their code in the lua file that's creating the frame immediatly after they create the frame!